5.4.3 Ternary Operator

OperatorOperationOperand 1Operand 2Operand 3Result type
?:conditionBoolanyanyany

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