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