From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Tuples

Tuples

- [Instructor] There's a really cool, but relatively unknown, data structure in Swift known as tuples. Tuples are differently typed data stored as one value. They're great for handling some quick cases you don't want to define in a full struct. Let's go ahead and explore some tuples here. Now a tuple literal is defined as a list of values of any type, enclosed in parentheses. In the exercise file, for example, I defined a pizza restaurant by its map coordinates and its name. So I have two doubles and a string here. You access each element of the tuple by using an index for a property. The first element is zero, then one, then two. I could turn this into a core location coordinate, for example, and I have one here that I have the literal values in the pizzaPlace and I'm going to go ahead and change them into the pizzaPlace versions of this. So I'm going to do pizzaPlace.0, and then come down here to longitude and I'm…

Contents