Logical Operators
Jyro uses word-based logical operators rather than symbols.
| Operator | Description |
|---|---|
not | Logical NOT (unary, right-associative) |
and | Logical AND (short-circuit, left-associative) |
or | Logical OR (short-circuit, left-associative) |
Short-Circuit Evaluation
andevaluates the right operand only if the left operand is truthyorevaluates the right operand only if the left operand is falsy
This is commonly used for null-safe property access:
if Data.user is not null and Data.user.active then
# Safe - Data.user.active is only evaluated when Data.user exists
end
Return Values
Logical operators return one of their operand values, not necessarily a boolean:
andreturns the first falsy operand, or the last operand if all are truthyorreturns the first truthy operand, or the last operand if all are falsynotalways returns a boolean
"hello" and "world" # "world" (both truthy → returns last)
null and "skipped" # null (first falsy → returns it)
null or "fallback" # "fallback" (first falsy → returns second)
"first" or "second" # "first" (first truthy → returns it)
not null # true
not "hello" # false
See Truthiness for the complete rules on which values are truthy and falsy.