Created
July 29, 2013 07:16
-
-
Save tosik/6102602 to your computer and use it in GitHub Desktop.
object や primitive と valueOf を絡めた AS3 のコンパイラとランタイムの挙動について
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
| var object:* = new Object; | |
| var foo:int = object; | |
| trace(foo); //=> 0 |
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
| class Foo | |
| { | |
| public function valueOf():int | |
| { | |
| return 123; | |
| } | |
| } | |
| var foo:int = new Foo(); // error |
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
| 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