0%

打破for循环嵌套

exitLoop: for i in 0...100 {
    print("i=\(i)")
    if i == 50 {
// break
    } else {
        for j in 0...100 {
            print("j=\(j)")
            if j == 50 {
                break exitLoop
            }
        }
    }
}

参考: https://www.hackingwithswift.com/example-code/language/how-to-break-out-of-multiple-loop-levels-using-labeled-statements

–EOF–