Swift brings a couple new things to iOS and Mac development, one of which is tuples. Tuples are a pretty nifty programming construct that have been around for a while, and are common in languages like Python. Pronounced either two-ple or tuh-pul(if you’re a Python dev this is the only way to pronounce it, the alternative is blasphemy), tuples are simply ordered sets of values and for our purposes they group multiple values into a single compound value.

Why is this important? In Objective-C, if you want a method to return more than one value you have two options - return a custom object with properties that store your return values or stick those values in a dictionary. With Swift however, we can use tuples to return more than one value. The values in a tuple can be of any type and don’t have to be the same type as each other. Despite being somewhat simple, you can actually do quite a few things with tuples.

Unnamed Tuples

To create a basic tuple, all we do is group values between parentheses and separate them by commas.