Alternative behaviour of && operator
I've faced such situation. I've used to program in C#, and such code:
if (condition1 && condition2){
//some actions
}
was asking both, condition1 and condition2 to be true
(the case when th开发者_如何学Pythoney both are giving false
and the end-result is true, could be achieved in other way).
In Flex, same code would perform "some actions" if the both conditions are false
. I just was wondering if is there any chance to make it break after finding first false
in a queue, or I have no choice and should write nested if
's?
Thanks in advance :)
ActionScript stops checking whenever it needs to.
if( false && true ){
}
This stops after the first false.
if( true && false ){
}
This stops after the second false.
if( true || false ){
}
This stops after the first true.
if( false || true ){
}
This stops after the second true.
Hope this helps...
In Flex (actually AS3 to be exact), if condition1 is false, condition2 is not checked.
精彩评论