The Freya Programming Language

Case statements

See also

The case statement selects one statement for execution according to the evaluation of a condition.

Syntax

This is the basic case statement syntax:

case expression of
    case-clause...
    otherwise-clauseopt
end

The case expression must return an integer value, an enumeration or a string value. First, the expression is evaluated, and a case clause is selected to match the expression result. A case clause is defined as a comma separated list of case labels:

case-label , ... : statement;

There are two kinds of case labels. This label kind is always available, no matter the type of the case expression:

expression

The second label kind is only available when the expression type is different from System.String:

expression .. expression

See also

The Freya Programming Language
Statements
if statement
Expressions