标签:
var sum = 0
for var i = 0; i < 10; i++ {
sum += i
}
print(sum)
for-in
,0..<10 表示从0到9sum = 0
for i in 0..<10 {
sum += i
}
print(sum)
sum = 0
for i in 0...10 {
sum += i
}
print(sum)
_
能够匹配任意类型_
表示忽略对应位置的值for _ in 0...10 {
print("hello")
}
标签:
原文地址:http://www.cnblogs.com/-liangjingjing/p/5350337.html