One, the tuple type is N any type of data composition (n>=0), the data that make up the tuple type can be called "element"
Two, the definition of the tuple
such as: let position = (X:10.5,Y:20)//Two elements of a tuple
Let person = (name: "Jack")//Element tuple
Let data = ()//0 elements of a tuple
Another example: let position = (10.5,20)//Omitting the element name of a tuple
Let person = ("Jack")//a tuple that omits element names
Another example: Var (x, y) = (10.5,20)
var (name) = ("Jack")
The above two methods do not declare the types of elements of a tuple, the system automatically determines its data type, it can also specify its own data type for each element of the tuple, and if the element type is specified, it is not possible to specify its name for the element, which is a syntax error.
For example: Var person: (int,string) = ("Jack")//correct
var person: (int,string) = (age:23,name: "Jack")//Error
Third, the tuple's access way
It can be viewed as an object or as an array
As the position above
1.position.x
2.position.0
Both of these methods can be accessed to 10.5
In addition, when a tuple is defined as a constant, all elements of the tuple are constants
For example: var person = ("Jack")
var (_,name) = person//Remove only the value of name
Swift's tuple type