General Information | |
Operator | ?: |
Type | ternary |
Syntaxe | expr ? expr : expr |
Operand Types | first operand is boolean, others are any type |
Result Type | type of the evaluated operand |
Functions | conditional evaluation: evaluates and returns the second operand if the first operand is true; otherwise evaluates and returns the second operand |
Expression Examples | |
expression | result |
true ? "hello" : "world" | "hello" |
true ? 2.3 : "world" | 2.3 |
1+1 == 2 ? (a := 3.1415926535) : nil | 3.1515926535 |
1 ? 3 : nil | raises an error: boolean expected, got integer. |