Chapter 9. Iterators, sequences, and collections
This chapter covers
- Taking a closer look at iteration in Swift
- Showing how Sequence is related to IteratorProtocol
- Learning useful methods that Sequence supplies
- Understanding the different collection protocols
- Creating data structures with the Sequence and Collection protocols.
You use iterators, sequences, and collections all the time when programming Swift. Whenever you use an Array, String, stride, Dictionary, and other types, you’re working with something you can iterate over. Iterators enable the use of for loops. They also enable a large number of methods, including, but not limited to, filter, map, sorted, and reduce.
In this chapter, you’re going to see how these iterators work, ...
Get Swift in Depth 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.