At the end of Chapter 6, Using Protocols and Protocol Extensions, we looked at the array structure provided in the Swift standard library. Now that we have a better understanding of protocol-oriented design, let's look at the protocol hierarchy for this structure again. The following diagram shows the protocol hierarchy:
As we can see, the protocol hierarchy for the array structure uses protocol-oriented design. Protocol inheritance is used in several places within the array protocol hierarchy. For example, the Collection protocol inherits from the Sequence protocol, and the MutableCollection protocol inherits from the Collection protocol.
Protocol composition is used because the array protocol inherits directly from eight different protocols. When you add in the protocol inheritance and composition, the array actually conforms to all 14 protocols shown...