Created
September 7, 2011 12:41
-
-
Save devboy/1200458 to your computer and use it in GitHub Desktop.
Wondering why this code throws no error at: changeValue("e");
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Sprite; | |
public class Test extends Sprite | |
{ | |
public function Test() | |
{ | |
var a:Value = new Value(); | |
a.str = "a"; | |
const changeValue: Function = function( to: String ): void | |
{ | |
trace( this ); | |
this.str = to; | |
} | |
changeValue.apply(a,["c"]); | |
trace( a.str ); // "c" | |
changeValue.call(a, "d"); | |
trace( a.str ); // "d" | |
changeValue("e"); // this is [global], has no .str method but no error is thrown | |
trace( a.str ); // "d" | |
} | |
} | |
} | |
internal class Value | |
{ | |
public var str:String; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment