Chapter 4. Collections

In the previous lesson, we looked into building Swift functions, error handling, and developing fully-featured Swift programs. We also briefly looked at a few OOP features.

In this lesson, we will work extensively with Swift's collections, such as arrays, sets, and dictionaries.

The Swift Standard Library (https://developer.apple.com/documentation/swift) is automatically imported into all Swift code, and contains basic types such as Int, Double, Bool, Optional, and more. It is primarily organized around protocols, because Swift is a Protocol-Oriented language (https://developer.apple.com/videos/play/wwdc2015/408/).

The root protocol for collections, which they all inherit from, is Sequence. All a type needs to conform to it ...

Get Beginning Swift 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.