Swift for-in循環
for-in 循環迭代項目,如數字範圍,數組中的項目,或字符串中的字符集:
語法
for-in 循環在 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)") }
當執行上麵的代碼,它產生以下結果:
Value of index is 11 Value of index is 22 Value of index is 33