Chapter    10

Tuples, Sets, and Structures

Variables are good for storing individual chunks of data while arrays and dictionaries are good for storing lists of the same data type. For greater flexibility, Swift also offers additional data structures called tuples and sets.

A tuple lets you store related data in one place that may consist of different data types such as a string and an integer, which could represent a person’s name and an employee ID number. A set is similar to an array or a dictionary in letting you store two or more chunks of data that consists of the same data type, such as strings or integers.

To group related data together, Swift also offers structures. With a structure, you can define the data type you want to group together ...

Get Swift OS X Programming for Absolute Beginners 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.