Skip to content

Instantly share code, notes, and snippets.

@tosik
Created July 29, 2013 07:16
Show Gist options
  • Select an option

  • Save tosik/6102602 to your computer and use it in GitHub Desktop.

Select an option

Save tosik/6102602 to your computer and use it in GitHub Desktop.
object や primitive と valueOf を絡めた AS3 のコンパイラとランタイムの挙動について
var object:* = new Object;
var foo:int = object;
trace(foo); //=> 0
class Foo
{
public function valueOf():int
{
return 123;
}
}
var foo:int = new Foo(); // error
class Foo
{
public function valueOf():int
{
return 123;
}
}
var foo:* = new Foo();
var bar:int = foo;
trace(foo); //=> [object Foo]
trace(bar); //=> 123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment