swift3.0 元组简单学习

前端之家收集整理的这篇文章主要介绍了swift3.0 元组简单学习前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//元组
//1.使用元组保存信息
let infoTuple = ("why",18,1.08)
let tupleName = infoTuple.0
let tupleAge = infoTuple.1
print(tupleName.characters.count)

//写法二//别名
let infoTuple1 = (name:"why",age:18,height:1.08)

infoTuple1.name
infoTuple1.age

//写法三//最常见,推荐的元组写法
let(name,age,height) = ("why",1.08)
name
age
height
原文链接:https://www.f2er.com/swift/321467.html

猜你在找的Swift相关文章