First we store the value we get from the timeElapsed method as a tuple and then switch on the tuple value. In the first case case(0, 0..<10) we are checking to see if the minute value is zero and the second value is between 0 and 9. If it is we only return the second value with a zero appended. Using a tuple lets us compare multiple values in a single switch statement. Let’s skip over the second case because it’s fairly easy to understand what’s going on there.

The third case is quite interesting. When the second value is below 10, we want to append a 0 in the string representation regardless of the minute value. In the tuple, by specifying an underscore for the minute value, we can chose to disregard it when pattern matching. In this case what we’re saying is regardless of the minute value as long as the second value is below 10, throw a zero in there.

Seemingly simple, tuples allow us to write more concise code and build more useful functions. If you want to learn more about Swift and how to use Swift in iOS development, including more about tuples, structs, enums, check out the iOS development with Swift Track on Treehouse!