swift 遍历

 

 

最简单的一个遍历数组

for 随便起个名字 in

升级

上面的看不懂的话,这个应该会简单点

 

 

import UIKit
let interestingNumbers = [
    "prime": [2,3,5,6,11,13],
    "prime1": [1,1,2,3,5,8],
    "prime2": [1,4,9,16,25],
]
var largest = 0
for (kind,numbers) in interestingNumbers {
    for number in numbers {
        if number > largest {
            largest = number
        }
    }
}
print(largest)

//////////////////////////
let hehe = [1:[22,33],2:[12,32]]
var xx = 0
for (name,array) in hehe {
    for number in array {
        print(number)
    }
}
////////////////////////

var intArray = [1,23,4,5]
for int in intArray {
    print(int)
}

 

posted on 2015-11-09 20:52  Zing_Z  阅读(320)  评论(0编辑  收藏  举报

导航