Possible Duplicate:
Does the compiler continue evaluating an expression where all must be true if the first is false?
Difference between eager operation and short-circuit operation? (| versu || and & versu &&)
So here’s my question. If I have this
if (Foo() && Bar())
DoStuff();
if Foo() returns false, will it still run through Bar()? or do I need to have
if (Foo())
if (Bar())
DoStuff();
to ensure that it only runs through the minimum amount needed before “failing out”?
In this case (logical AND) it will firstly check
Foo()return value and will doBar()only ifFoo()returns true. Simply if any of conditions is false then it will not check others, it will check conditions from left to right.