Created
July 3, 2013 02:14
-
-
Save tobyhede/5914924 to your computer and use it in GitHub Desktop.
Coffeescript super argument ordering. See the snake.
This file contains 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 Animal | |
constructor: (@name) -> | |
move: (meters, direction = "north") -> | |
console.log @name + " moved #{direction} #{meters}m." | |
class Snake extends Animal | |
move: (direction = "south", meters = 5) -> | |
console.log "Slithering..." | |
super meters, direction | |
class Horse extends Animal | |
move: -> | |
console.log "Galloping..." | |
super 45 | |
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