Tuples group multiple values into a single compound value. Unlike arrays and dictionaries, the values in a tuple do not have to be of the same type. While tuples are included in this chapter about collections, they actually behave more like a custom type than a collection.
The following example shows how to define a tuple:
var team = ("Boston", "Red Sox", 97, 65, 59.9)
In the preceding example, an unnamed tuple was created that contains two strings, two integers, and one double. The values of the tuple can be decomposed into a set of variables, as shown in the following example:
var team = ("Boston", "Red Sox", 97, 65, 59.9) var (city, name, wins, loses, percent) = team
In the preceding code, the city variable will contain Boston ...