or
is a logical binary operation. It has the lowest priority across all
binary operations.
or works on booleans and null with the following
rules:
| boolean logic |
tri-state logic |
a |
b |
a or b |
| false |
false |
false |
| false |
true |
true |
| true |
false |
true |
| true |
true |
true |
|
a |
b |
a or b |
| null |
false |
null |
| false |
null |
null |
| null |
true |
true |
| true |
null |
true |
|
or has short-circuiting: if the first argument is true,
then the second argument is not evaluated, true is returned straight
away.
binary expression, $result will be
true |
$result := true or false |
binary expression, $result will be
null |
$result := null or null |
short-circuiting, the expensive call is never called,
$result will be true |
$result := true or (expensive call) |
or is not a keyword |
print or/x # OK
print "or/x" # same as previous
|
See Also