Created
July 27, 2013 09:37
-
-
Save back2dos/6094394 to your computer and use it in GitHub Desktop.
Fun with abstracts: grouping members without overhead.
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 ; | |
| abstract Animals(ExampleData) from ExampleData { | |
| public var dog(get, never):Animal; | |
| inline function get_dog():Animal return this.dog; | |
| public var cat(get, never):Animal; | |
| inline function get_cat():Animal return this.cat; | |
| public var cow(get, never):Animal; | |
| inline function get_cow():Animal return this.cow; | |
| } |
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 ; | |
| abstract Example(ExampleData) { | |
| public var animals(get, never):Animals; | |
| public var fruit(get, never):Fruit; | |
| inline function get_animals():Animals return this; | |
| inline function get_fruit():Fruits return this; | |
| } |
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 ; | |
| class ExampleData { | |
| public var dog:Animal; | |
| public var cat:Animal; | |
| public var cow:Animal; | |
| public var orange:Fruit; | |
| public var banana:Fruit; | |
| public var apple:Fruit; | |
| } |
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 ; | |
| abstract Fruits(ExampleData) from ExampleData { | |
| public var orange(get, never):Fruit; | |
| inline function get_orange():Fruit return this.orange; | |
| public var banana(get, never):Fruit; | |
| inline function get_banana():Fruit return this.banana; | |
| public var apple(get, never):Fruit; | |
| inline function get_apple():Fruit return this.apple; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment