Last active
December 17, 2015 18:19
-
-
Save ELLIOTTCABLE/5652573 to your computer and use it in GitHub Desktop.
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
| # `construct()` comes from: | |
| # https://github.com/elliottcable/Paws.js/blob/84c75de3ec6f829501bfdc9d0d6e472b31ed7d9a/Source/utilities.coffee#L39-L47 | |
| Label: class Label extends Thing | |
| constructor: (string) -> | |
| it = construct this | |
| super.apply(it) | |
| it.alien = new String string | |
| it.alien.native = this | |
| return it |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Of note:
construct()approach taken here is about to be replaced with a bit more “magic” metaprogrammatic approach, with a higher-level function (constructify()?) that automatically wraps our constructor such that it operates the same way we've got it working here with an explicitconstruct()stringfor a performance enhancement elsewhereit, as CoffeeScript doesn't treat constructors the way it treats everything else (understandably.) when it comes to return values; without an explicitreturn, which CoffeeScript won't automatically provide here, JavaScript returns the originalthisof the function, which we're changing.