Answer the question
In order to leave comments, you need to log in
In the "&&" check, will the second part fail if the first part is false?
In the "&&" check, will the second part fail if the first part is false? if(a ==1 && b == 2)
If a is false, then b will not be executed?
Answer the question
In order to leave comments, you need to log in
Depends on the programming language. For example, VisualBasic has two operators, And and AndAlso. And always evaluates both arguments, AndAlso evaluates the second argument only if the first one is true.
Yes. Have you ever seen the design?if(Obj != null && Obj.field != null) { }
Yes. In C+, this is the so-called "short scheme". If the result of the first part allows you to unambiguously obtain the result of the entire expression, the rest of the expression is not calculated. The situation is the same with the || operator. Rumor has it that if you override these operators, then the "shortcut" won't work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question