Collection data types are types that can store multiple values of the same or different types in an organized way. Swift provides three primary collection types: arrays, sets, and dictionaries.
- Arrays are ordered collections of values that can be accessed by an integer index. Arrays can store duplicate values and can be modified after creation.
- Sets are unordered collections of unique values that can be tested for membership and combined using set operations. Sets cannot store duplicate values and can be modified after creation.
- Dictionaries are unordered collections of key-value pairs that can be accessed by a unique key. Dictionaries can store different types of values for different keys and can be modified after creation.
You can also create your own custom collection types by conforming to the Collection protocol.
This series of tutorials will tell you everything you need to know to confidently deal with Swift collections in real life. Let’s roll up your sleeves and get started!