This type of rating is called short-circuiting . When the result is 100% understandable, it will not continue to evaluate.
This is actually a common programming method. For example, in C ++ you often see something like:
if (pX!=null && pX->predicate()) { bla bla bla }
If you change the order of the conditions, you can call the method with a null pointer and fail. A similar example in C would use a structure field if you have a pointer to that structure.
You can do something like this with or:
if(px==null || pX->isEmpty()} { bla bla bla }
This is also one of the reasons why it is generally recommended to avoid side effects in the if condition.
For example, suppose you have:
if(x==4 && (++y>7) && z==9)
If x is 4 , then y will increase regardless of the value of z or y , but if x not 4 , it will not increase at all.
Uri Mar 16 '10 at 16:20 2010-03-16 16:20
source share