Skip to content

Continue Statement

IsaacShelton edited this page Mar 21, 2022 · 1 revision

Continue

The continue keyword is used to jump back to the start of a loop

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

Loop Labels

A specific loop can be specified using loop labels

each outer_loop : enemy Enemy in enemies {
    each stat Stat in enemy.stats {
        if stat.kind == StatKind::IS_INVINCIBLE, continue outer_loop
    }
    if enemy.health <= 0 {
        enemies.remove(idx--)
    }
}
Clone this wiki locally