Skip to main content

Value Conditional

rascal-0.34.0

Synopsis

Conditional expression on values.

Syntax

Exp₁ ? Exp₂ : Exp₃

Types

Exp₁Exp₂Exp₃Exp₁ ? Exp₂ : Exp₃
boolT₂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}