Short-circuit evaluation

ID: short-circuit-evaluation

Evaluation that skips a later operand once an earlier operand determines the result. In Scala, p != null && p.field == x does not dereference p when it is null, and i < n && a(i) != x avoids an out-of-range access at . The order is part of the safety argument: exchanging these operands can preserve a Boolean formula in mathematics while changing whether a program raises an exception.

New to topics? Read the docs here!