Tuples allow you to store several values together in a single value. That might sound like arrays, but tuples are different:
Tuples are created by placing multiple items into parentheses, like this:
var name = (first: "Taylor", last: "Swift")
You then access items using numerical positions starting from 0:
Or you can access items using their names:
Remember, you can change the values inside a tuple after you create it, but not the types of values. So, if you tried to change
name to be
(first: "Justin", age: 25) you would get an error.
SPONSORED Instabug helps you identify and resolve severe crashes quickly. You can retrace in-app events and know exactly which line of code caused the crash along with environment details, network logs, repro steps, and the session profiler. Ask more questions or keep users up-to-date with in-app replies straight from your dashboard. Instabug takes data privacy seriously, so no one sees your data but you! See more detailed features comparison and try Instabug's crash reporting SDK for free.
The biggest ever Hacking with Swift sale is now on, letting you save 50% on all books and bundles. Learn something new with Swift and enjoy great savings while the sale lasts!