var btn:Button;
if(btn != null && btn.label != '') {
mx.controls.Alert.show("d");
}
In the above if clause, is it guaranteed that the first condition(btn != null) will be evaluated before the second condition?
var btn:Button;
if(btn != null && btn.label != '') {
mx.controls.Alert.show("d");
}
In the above if clause, is it guaranteed that the first condition(btn != null) will be evaluated before the second condition?
Yes - ActionScript performs appropriate short-circuiting for the &&
operator:
So not only will it evaluate the expressions in the order you described, it won't bother evaluating the second expression at all if the first one returns false
(which is as important a detail as the order of evaluation).
Just as a note, ActionScript also supports short-circuiting the logical or operator (||
).
Yes it is. Excerpts from the Adobe livedocs regarding &&
operator:
&&
logicalAND
Operator:Usage:
expression1 && expression2
Returns
expression1
if it isfalse
or can be converted tofalse
, andexpression2
otherwise.