简单的for循环
1 2 3 4 5 |
var arr = String[]() for index in 0..100{ arr.append("Item(index)") } println(arr) |
遍历数组
1 2 3 |
for value in arr{ println(value) } |
while循环遍历
1 2 3 4 5 |
var i = 0 while i<arr.count{ println(arr[i]) i++ } |
遍历字典
1 2 3 4 5 6 7 8 |
var dict = ["name":"superyyl","age":"16"] for (key,value) in dict{ println("(key),(value)") } /* name,superyyl age,16 */ |