Value Conditional
rascal-0.40.17
Synopsis
Conditional expression on values.
Syntax
Exp₁ ? Exp₂ : Exp₃
Types
Exp₁ | Exp₂ | Exp₃ | Exp₁ ? Exp₂ : Exp₃ |
---|---|---|---|
bool | T₂ | T₃ | lub(T₂,T₃) |
Description
Yields the value of Exp₂ if the value of Exp₁ is true
and the value of Exp₃ otherwise.
The result type is the least upper bound (also known as lub
, see StaticTyping) of the types of Exp₂ and Exp₃.
Examples
rascal>( 3 > 2 ) ? 30 : 40;
int: 30
rascal>( 3 < 2 ) ? "abc" : {3, 4};
set[int]: {3,4}