/documentation/coffee/classes.coffee
http://github.com/jashkenas/coffee-script · CoffeeScript · 21 lines · 16 code · 5 blank · 0 comment · 0 complexity · f6afff56d42a4296147b583221eabf20 MD5 · raw file
- 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()