Navigation
Synopsis Conditional expression on values.
Syntax Exp1 ? Exp2 : Exp3
Types
Exp1 Exp2 Exp3 Exp1 ? Exp2 : Exp3
bool T2 T3 lub(T2,T3)
Description Yields the value of Exp2 if the value of Exp1 is true and the value of Exp3 otherwise. The result type is the least upper bound (also known as lub, see StaticTyping) of the types of Exp2 and Exp3.
Examples
rascal>( 3 > 2 ) ? 30 : 40;
int: 30
rascal>( 3 < 2 ) ? "abc" : {3, 4};
set[int]: {3,4}
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.