In a short-circuit logic, i.e. a logical OR operation (denoted via ||
), the evaluation is stopped when a sub-expression in it evaluates to true
whereas in a non-short circuit logic, i.e. a bitwise OR operation (denoted via |
), the entire expression is evaluated. The highlighted condition is an example of non-short circuit logic and is likely a mistake and should have been a short-circuit logic instead.
// Both `condition1` and `condition2` are evaluated.
if (condition1 | condition2)
{
// ...
}
// `condition2` is evaluted only if `condition1` evaluates to `false`
if (condition1 || condition2)
{
// ...
}