Short-Circuit OR, ||
Logical OR with short-circuiting
Syntax
Description
represents
a logical expr1
|| expr2
OR
operation that employs Logical Short-Circuiting behavior. That is, expr2
is not evaluated if expr1
is logical 1
(true
). Each expression must evaluate to
a scalar logical result.
Examples
Input Arguments
More About
Tips
When you use the element-wise
&
and|
operators in the context of anif
orwhile
loop expression (and only in that context), they use short-circuiting to evaluate expressions.However, you should always use the
&&
and||
operators to enable short-circuit evaluation. Using the&
and|
operators for short-circuiting can yield unexpected results when the expressions do not evaluate to logical scalars.
Extended Capabilities
Version History
Introduced before R2006a