saker.build Documentation TaskDoc JavaDoc Packages
  1. saker.build
  2. ›
  3. Scripting language
  4. ›
  5. Language reference
  6. ›
  7. Operators
  8. ›
  9. Ternary

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.