Skip to content

Fallthrough

IsaacShelton edited this page Mar 21, 2022 · 1 revision

Fallthrough

The fallthrough keyword is used inside switch statements to fall though into the next block

switch animal_kind {
case AnimalKind::CAT
    if animal_sub_kind != AnimalSubKind::TIGER {
        fallthrough
    }
    print("The animal is a tiger")
case AnimalKind::DOG
    print("The animal is a cat or dog")
}

See switch for more information

Clone this wiki locally