I received a lot of feedback about protocol-oriented programming after the first version of this book was released. Almost all the feedback was very positive; however, there was one conversation that I had—with one of the smartest people that I have had the privilege to meet—about what protocol-oriented programming was. One of the comments he made was that I should not forget about generic programming. The conversation we had about generic programming really stuck with me and when I had the opportunity to write a new version of this book, I took the opportunity to include this chapter on generics.
In this chapter, we will learn about the following:
- What generics are
- How to create generic functions
- How to create generic types
- How to use generic subscripts
- How to implement copy-on-write (COW)
- How to design flexible and reusable types with protocols and generics...