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