for-in循环遍历项目集合,如数字范围、数组中的项目或字符串-中的字符
SWIFT 4编程语言中for-in循环语法为-
for index in var { statement(s) }
var someInts:[Int]=[10, 20, 30] for index in someInts { print( "Value of index is\(index)") }
执行上述代码时,将生成以下结果-
链接:https://www.learnfk.comhttps://www.learnfk.com/swift/swift-for-in.html
来源:LearnFk无涯教程网
Value of index is 10 Value of index is 20 Value of index is 30
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)