label@ for(i in 1..10) { label2@ for (j in 0..i) { if (j == 3) { break[@label](https://my.oschina.net/u/192755) } else { println("(${i},${j})") } } println("inner ok") } println("outer ok")
此段代碼當break時就會直接跳到外層循環外;執行結果以下.net
(1,0) (1,1) inner ok (2,0) (2,1) (2,2) inner ok (3,0) (3,1) (3,2) outer ok