The logical AND and logical OR operators (&&
, and ||
, respectively) exhibit "short circuit" operation. That is, the second operand is not evaluated if the result can be deduced solely by evaluating the first operand. Consequently, the second operand should not contain side effects because it would not be apparent whether the side effect occurs.
Non-Compliant Code Example
In this the following non-compliant code example, the value of i
is incremented only when i >= 0
.
...