Documentation TaskDoc JavaDoc Packages
  2. Scripting language
  3. Language reference
  4. Operators
  5. Ternary


The ternary operator is an expression that takes 3 operands and returns different values based on a conditions. Its working is similar to common programming languages, and it basically functionals like a miniature if-else statement that returns a value. It's a mixture of a control statement and expression.

# evaluates to 123 if $condition is true, 456 if false
$var = $condition ? 123 : 456

The condition expression is evaluated the same way as the if-else statement does.