如果使用嵌套循环(即,另一个循环中的一个循环),则break语句将停止执行最里面的循环,并开始执行该块之后的下一行代码。
break - 语法
SWIFT 4中BREAK语句语法如下所示:-
break
break - 流程图

break - 示例
var index=10repeat { index=index + 1 if( index == 15 ){ break } print( "Value of index is(index)") } while index < 20
编译并执行上述代码时,将生成以下结果-
Value of index is 11 Value of index is 12 Value of index is 13 Value of index is 14
<h2 id="h22">参考链接</h2><p><a target="_blank" href="https://www.learnfk.com/swift/swift-break-statement.html" style="">https://www.learnfk.com/swift/swift-break-statement.html</a></p>