I recently discovered that Java (and Scala) include non-short-circuiting logical operators &
, |
, and ^
. I previously thought thes
Using the non-short-circuit boolean operators implies that the operands have side effects. If they had no side effects, then the programmer could have used the short-circuit versions with no change in functionality.
In code written in a functional style (which Scala surely encourages but does not require), side effects are an indication that something unusual is going on. Unusual things should be clearly indicated in code, rather than by something as subtle as a non-short-circuit boolean operator.