1.Tuples元组
定义: 将多个不同的值集合成一个数据
特点:可以任意多值|不同的值可以是不同类型
let Tuples = (123,"jiangchao")
print("元组的元素\(Tuples.0)")
let (left,right) = Tuples
print("元组第二种方法\(right)")
//使用下划线_忽略部分数值
let loginResult = (true,"jiangchao")
let (isLoginSuccess,_) = loginResult
if isLoginSuccess {
print("登陆成功")
}
2.循环运算符
For in
a...b a..<b
for index in 1...10{
print(index)
}
let names = ["唐僧","孙悟空","猪八戒","沙悟净"];
for i in 0..<names.count{
names[i]
}
网友评论