© Wallace Wang 2017

Wallace Wang, macOS Programming for Absolute Beginners, 10.1007/978-1-4842-2662-9_10

10. Tuples and Sets

Wallace Wang

(1)San Diego, California, USA

Variables are good for storing individual chunks of data, and arrays and dictionaries are good for storing lists of related data. 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 related data such as strings or integers.

Perhaps the biggest advantage of both tuples and ...

Get macOS Programming for Absolute Beginners: Developing Apps Using Swift and Xcode 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.