1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/documentation/coffee/super.coffee

26 lines
391 B
CoffeeScript
Raw Normal View History

Animal: ->
Animal::move: (meters) ->
2010-01-25 00:14:00 -05:00
alert this.name + " moved " + meters + "m."
2009-12-21 11:41:45 -05:00
Snake: (name) -> this.name: name
Snake extends Animal
Snake::move: ->
2010-01-25 00:14:00 -05:00
alert "Slithering..."
super 5
2009-12-21 11:41:45 -05:00
Horse: (name) -> this.name: name
Horse extends Animal
Horse::move: ->
2010-01-25 00:14:00 -05:00
alert "Galloping..."
super 45
2009-12-21 11:41:45 -05:00
2010-01-25 00:14:00 -05:00
sam: new Snake "Sammy the Python"
tom: new Horse "Tommy the Palomino"
2009-12-21 11:41:45 -05:00
sam.move()
tom.move()
2009-12-24 01:22:41 -05:00