for-in 循環(huán)迭代項目,如數(shù)字范圍,數(shù)組中的項目,或字符串中的字符集:
for-in 循環(huán)在 Swift 編程語言的語法:
for index in var {
statement(s)
}

import Cocoa
var someInts:[Int] = [11, 22, 33]
for item in someInts {
println( "Value of index is \(item)")
}
當(dāng)執(zhí)行上面的代碼,它產(chǎn)生以下結(jié)果:
Value of index is 11 Value of index is 22 Value of index is 33