Some languages ββuse either a short circuit, or others use a full logical evaluation (if you know, this is similar to the $B directive in pascal)
Explanations:
function A(){ ...do somethings.. return true; } function B(){ ...do somethings.. return true; } if ( A() OR B() ) { .....
In this example, function B() will never be executed. Since the A() function returns TRUE, the result of the OR operation is known from the first part without the need to evaluate the second part of the expression.
However, with ( A() || B() ) second part is always evaluated regardless of the value of the first.
For optimized programming, you should always use OR , which is faster (unless the first part returns false and the second part needs to be evaluated).
janhsh Oct 05 '14 at 2:54 on 2014-10-05 14:54
source share