Tuples元组,相对OC swift新添加的结构,可以存放不同类型的数据,可以作为函数的参数和返回值,作为返回值时,可以实现函数返回多个数据。
Tuples创建:
隐式: var tup = ("何小贱",23,ture)
var tup = (name:"何小贱",age:23,Bool:ture)
显示:var tup:(name:String,age:Int,gender:Bool) = ("何小贱",23,true)
var (name ,age ,gender) = ("何小贱",23,true)
Tuples使用:(对应上面4中创建方式)
tup.0 = "__何小贱"
tup.name = "__何小贱"
tup.name = "__何小贱"
name = "__何小贱"
网友评论