Type Eraser

    Problem

    Let’s circumvent the problem

    The example from the previous lesson is used.

    Design Wrapper

    Use to create an object.

    You may group items whose FileType is identical.

    References

    Beyond Crusty: Real-World Protocols by Rob Napier

    Conclusion

    The lesson could have been tough since it assumes you’ve mastered generics and closures. If you are stuck, I recommend you to get the fundamentals of them and then come back after. If you wish to study more, I recommend you to take a look at the references I’ve attached. They focus on why Protocol Oriented Programming is not the ultimate savior for all cases. Often, it is recommended you use pure structs or enums which you will learn in-detail in the following chapter. Anyhow, the person who came up with the solution is definitely smarter than I’m.