Note: information on this page refers to Ceylon 1.0, not to the current release.
else operator
The left-associative, binary else operator is used to provide a default value
when it's left operand is null.
Usage
void m(String? s) {
String s2 = s else "";
}
Description
The else operator is defined as follows
if (exists lhs) then lhs else rhs
See the language specification for more details.
The then operator is often used with the else operator to emulate
C's ternary operator cond ? when-true-expr : when-false-expr, like so
T|F result = cond then whenTrueExpr else whenFalseExpr;
Type
The result type of the else operator is given by the type expression Lhs&Object|Rhs, wher
Lhs is the type of the left hand operand and
Rhs is the type of the left hand operand.