Tuples are unique in swift, and there is no correlation type in OC
/*
It is a data structure, which is widely used in mathematics.
Similar to arrays or dictionaries
You can define a set of data
The data that makes up the tuple type is called the "element"
*/
The difference between a tuple, an array, and a dictionary
1. Use arrays to define a set of data
Let Infoarray = ["Wenjian", 18,1.88]
Gets the elements in the array
Let NameArray = infoarray[0]
2. Use a dictionary to define a set of data
Let infodict = ["Name": "Wenjian", "age": +, "height": 1.88]
Get the elements in the dictionary
Let namedict = infodict["Name"]
3. Use tuples to define a set of data
Let Infotuple = ("Wenjian", 18,1.88)
Gets the elements in the tuple
Let nametuple = infotuple.0
4. Using tuples to define a network request error
Array
Let Errorarray = ["Not Found", 404]
Dictionary
Let errodict = ["erromsg": "Not Found", "Errocode": 404]
Meta-group
Let Errotuple = ("Not Found", 404)
errotuple.0
Alias all elements in a tuple
Let ErroTuple1 = (erromsg: "Not Found", errocode:404)
Errotuple1.erromsg = = erroTuple1.0
Errotuple1.errocode = = erroTuple1.1
The tuple's alias is the name of the tuple
Let (erromsg,errocode) = ("Not Found", 404)
Erromsg
Errocode
Swift language----tuples