Note: information on this page refers to Ceylon 1.1, not to the current release.
then
operator
The left-associative, binary then
operator evaluates its right operand only
when it's left operand is true
, otherwise it evaluates as null
.
Usage
void m(String s) {
String s2 = s.empty then "hello";
}
Description
The then
operator is defined as follows
if (lhs) then rhs else null
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 then
operator is the optional type of the right hand operand;