📅  最后修改于: 2021-01-11 07:36:35             🧑  作者: Mango
Swift 4 break语句在两种情况下使用:
在嵌套循环的情况下,break语句终止最内层的循环并开始执行该块之后的下一行代码。
Swift 4 break语句的语法为:
break
Swift 4 break语句流程图
var index = 10
repeat {
index = index + 1
if( index == 25 ){
break
}
print( "Value of index is \(index)")
} while index < 30
输出:
Value of index is 11
Value of index is 12
Value of index is 13
Value of index is 14
Value of index is 15
Value of index is 16
Value of index is 17
Value of index is 18
Value of index is 19
Value of index is 20
Value of index is 21
Value of index is 22
Value of index is 23
Value of index is 24