Skip to content

Instantly share code, notes, and snippets.

@devboy
Created September 7, 2011 12:41
Show Gist options
  • Save devboy/1200458 to your computer and use it in GitHub Desktop.
Save devboy/1200458 to your computer and use it in GitHub Desktop.
Wondering why this code throws no error at: changeValue("e");
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