Lynxer

Documentation

Conditionals

if / elif / else

if (n > 0) {
    println("positive");
} elif (n is 0) {
    println("zero");
} else {
    println("negative");
}

else if is also accepted and behaves like elif.

switch / case / default

Cases are written case(pattern){ ... }; there is no colon form and no break fallthrough — the first matching case runs, then the switch ends.

switch (x) {
    case(1){ println("one"); }
    case(2){ println("two"); }
    default(){ println("other"); }
}

A pattern may destructure an enum payload and binds names for the body (see enums):

switch (result) {
    case(status.Ok(value)){ println("ok ", value); }
    case(status.Failed(reason)){ println("failed ", reason); }
}

See also