3 Collections
Collections are sets of variables glued together as logical units. This chapter will teach you about collection types in Swift.
Now that you’ve learned about individual variables, you can advance your Swift journey with collections. In a nutshell, collections are data structures that group multiple variables into a single, organized container. Nearly all programming languages use collections—including Swift.
There are three main types of collections, which are the subject of this chapter:
-
Arrays are ordered variable lists in which each variable has an index.
-
Sets are unordered variable lists in which each value must be unique.
-
Dictionaries are key-value pairs in which each key must be unique.
To paraphrase a possible question ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access