Created
September 7, 2011 05:31
-
-
Save dcadenas/1199842 to your computer and use it in GitHub Desktop.
Desugared Coffeescript class definitions
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
| #sugared | |
| do -> | |
| class Animal | |
| constructor: (@name) -> | |
| move: (meters) -> | |
| alert @name + " moved #{meters}m." | |
| class Snake extends Animal | |
| move: -> | |
| alert "Slithering..." | |
| super 5 | |
| class Horse extends Animal | |
| move: -> | |
| alert "Galloping..." | |
| super 45 | |
| sam = new Snake "Sammy the Python" | |
| tom = new Horse "Tommy the Palomino" | |
| sam.move() | |
| tom.move() | |
| #desugared | |
| do -> | |
| Animal = do -> | |
| Animal = (@name) -> | |
| Animal::move = (meters) -> | |
| alert @name + " moved #{meters}m." | |
| Animal | |
| Snake = do -> | |
| Snake = -> super | |
| Snake extends Animal | |
| Snake::move = -> | |
| alert "Slithering..." | |
| super 5 | |
| Snake | |
| Horse = do -> | |
| Horse = -> super | |
| Horse extends Animal | |
| Horse::move = -> | |
| alert "Galloping..." | |
| super 45 | |
| Horse | |
| sam = new Snake "Sammy the Python" | |
| tom = new Horse "Tommy the Palomino" | |
| sam.move() | |
| tom.move() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment