Home > database >  Swift: Does Array conforms to Sequence Protocol?
Swift: Does Array conforms to Sequence Protocol?

Time:11-11

I found out that Array has makeIterator() method.
As I know, makeIterator() is required by the Sequence protocol.
But I couldn't find the fact that Array conforms to Sequence.

Does Array conforms to Sequence protocol?

CodePudding user response:

You can find what protocols built-in types conform to in their documentation. There is a Relationships section at the bottom of their documentation pages.

If you check the docs of Array, you can see that it conform to MutableCollection, which inherits from Collection, which inherits from Sequence. So yes, Array does conform to Sequence via its MutableCollection conformance.

  • Related