首页 > 代码库 > Swift3.0 元组 (tuples)

Swift3.0 元组 (tuples)

//元组
//不需要的元素用 _ 标记
let (name,age,_) = ("明明","10","")
print(name,age)

//通过下标访问特定的元素
let student = ("明明","10","")

print(student.0,student.1,student.2)

let bobo = (name:"波波",age:"24")
print(bobo.name,bobo.age)

 

Swift3.0 元组 (tuples)