On Jun 19, 2010, at 10:33 PM, dorkie dork from dorktown wrote:

> 
> 
> Right but the compiler is already hoisting, which means it moves all variable 
> declarations to the top of the function. For example, the following code 
> compiles even though the initial trace() function for the num variable 
> happens before the num variable is declared:
> trace(num); // NaN
> var num:Number = 10;
> trace(num); // 10
> The compiler will not, however, hoist any assignment statements. But it could 
> use the assignment statements to dynamically type the variable. So then:
> 
> var x = new A();
> 
> var x;
> x = new A();
> 
> would be the same

It can't be. What happens in this case?

var x;
if (y == 1) {
   x = new A();
} else {
   x = new B();
}

--
Rick Genter
rick.gen...@gmail.com

Reply via email to