To break from the outer loop, add a label prior to the outer While loop:
var i = 0 outerLoop: while i<3 { i = i + 1/* www .j a v a 2s . com*/ var j = 0 while j<3 { j = j + 1 print("(\(i),\(j))") break outerLoop //exit the inner While loop } }
You can specify which While loop you are trying to break out of by specifying the label outerLoop.
You can use the labeled statement with the continue keyword:
var i = 0 outerLoop: while i<3 { i++/* w w w . java2 s.c om*/ var j = 0 while j<3 { j++ print("(\(i),\(j))") continue outerLoop //go to the next iteration of the // outer While loop } }