Skip to content

Break Statement

IsaacShelton edited this page Mar 21, 2022 · 1 revision

Break

The break keyword is used to jump out of a loop

for(i usize = 0; i < 5; i++){
    if i == 3, break
    print(i)
}
0
1
2

Loop Labels

A specific loop can be specified using loop labels

for outer_loop : (i usize = 0; i < 10; i++){
    each Animal in animal_catagories[i] {
        if it.isDead(), break outer_loop
    }
}
Clone this wiki locally