Short circuit
A
short circuit is a fault in
electrical apparatus whereby
electrical current is allowed to flow between a phase and the electrical earth or between two phases.
Short circuits are usually caused when a breakdown of insulation occurs, or when a conducting medium, such as water allows current to flow.
Short circuits can cause significant damage to electrical installations, which are normally protected by fuses, circuit breaker or other overload protection.
In
computer programming,
short circuiting is a method of evaluating boolean expressions in which only the first argument of the
and and
or operators is evaluated if this is sufficient to determine the value overall. In the case of
and, if the first argument is false, the whole expression is false, and the second argument is not evaluated. In the case of
or, if the first argument is true, the whole expression is true, and the second argument is not evaluated. Not only may this eliminate expensive computation in the second argument, but it allows a style of programming where the first argument first checks a condition without which the second argument may cause a run-time error.