HomeManualTopicsTypesSymbols

std::cond

a multiway conditional expression or statement

Parameter

args*
a sequence of functions that return a boolean and a function

Result

results
whatever the selected function returns

Description

Each argument is a function that returns two results:

  • a boolean value (std::true or std::false)

    and

  • a function (statement sequence)

    The arguments are evaluated in order and as soon as an argument returns std::true the corresponding function is called.

    If none of the arguments returns std::true no function is called.

    Example

    $chr '7' cond -> chr >= 'a' && chr <= 'z': println! "lower case character" -> chr >= 'A' && chr <= 'Z': println! "upper case character" -> chr == '_': println! "underscore" -> chr >= '0' && chr <= '9': println! "digit" -> true: println! "neither character nor digit nor underscore"

    Output

    digit

    Topic

    Branches

    See also

    std::if classic if; can be used as a function or a procedure
    std::case a multiway conditional expression or statement