if

Executes a list of statements if a boolean condition is true. Optionally, one may add one or more elseif-branches to add more conditions that are evaluated if previous conditions are false, and a final else that is executed if none of the conditions were true.

Syntax

    if boolean-expression then
        block-of-code
    endif;

or

    if boolean-expression then
        block-of-code
    else
        block-of-code
    endif;

or

    if boolean-expression then
        block-of-code
    elseif boolean-expression then
        block-of-code
    else
        block-of-code
    endif;

Example

    charCode = readChar();
    if charCode == 'y' then
        println("yes");
    elseif charCode == 'n' then
        println("no");
    else
        println("maybe");
    endif;