Break & continue

To control the flow of a loop, we have two keywords break and continue.

Break

Break is used to terminate the loop.

Syntax

break

Examples

Breaking down an infinite loop

while true {
    break
}

var i = 1

while i++ < 10 {
    if i == 5 {
        break
    }
    else {
        puts i
    }
}

Continue

Continue is used to continue the loop contidion.

Syntax

continue

Examples



for {
    
}

Last updated

Was this helpful?