Tsallaka zuwa abun ciki
Justice Tech School

break, continue and Labels

break leaves a loop, continue skips a round and labels target outer loops.

Example
outer@ for (i in 1..3) {
    for (j in 1..3) {
        if (j == 2) continue
        if (i == 3) break@outer
        println("$i $j")
    }
}

Exercise

Label syntax.

outer for

Quiz Test

What does break@outer do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.