Operator | Operation | Operand 1 | Operand 2 | Operand 3 | Result type |
---|---|---|---|---|---|
?: | condition | Bool | any | any | any |
The type of operand 2 and operand 3 must unify. The unified type is used as the result type of the expression.
The ternary conditional operator is a shorter form of if
:
trace(true ? "Haxe" : "Neko"); // Haxe trace(1 == 2 ? 3 : 4); // 4 // equivalent to: trace(if (true) "Haxe" else "Neko"); // Haxe trace(if (1 == 2) 3 else 4); // 4