Nesting and labels

It's possible to break or continue out loops or match statements when dealing with nested loops and match statements. In these cases, the statements must be annotated with some name, and the label's name must be passed the break or continue statement.

import "fmt.odin";

main :: proc() {
    outer: for {
        fmt.println("Entered outer loop");
        inner: for {
            fmt.println("Entered inner loop");

            // This would break only the inner loop
            // break; 

            // This breaks the outer loop
            break outer;
        }

        fmt.println("Never called");
    }
    fmt.println("Exited the outer loop");
}

results matching ""

    No results matching ""