Summary

In this chapter, you learned how to maximize code reuse by writing code capable of working with objects of different types, that is, instances of classes that conform to specific protocols or whose class hierarchy includes specific superclasses. We worked with protocols and generics. We created classes capable of working with one or two constrained generic types.

We combined inheritance, protocols, and extensions to maximize the reusability of code. We could make classes work with many different types.

Now that you have learned about parametric polymorphism and generics, we are ready to combine object-oriented programming and functional programming, which is the topic of the next chapter.

Get Swift 3 ObjectOriented Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.