tags:

views:

38

answers:

2
var b:Boolean = condition1() && condition2();

In this statement, if condition1() evaluates to false, will condition2() be evaluated?

+4  A: 

Yes. The && operator (and also ||) is short-circuited.

This has been explained in http://192.150.14.22/livedocs/flash/9.0/ActionScriptLangRefV3/operators.html#logical_AND.

Returns expression1 if it is false or can be converted to false, and expression2 otherwise. Examples of values that can be converted to false are 0, NaN, null, and undefined. If you use a function call as expression2, the function is not called if expression1 evaluates to false.

KennyTM
+2  A: 

A little googling indicates yes. Also, the usual term is short-circuited, rather than lazy.

Blorgbeard