PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1class Animal
 2  constructor: (@name) ->
 3
 4  move: (meters) ->
 5    alert @name + " moved #{meters}m."
 6
 7class Snake extends Animal
 8  move: ->
 9    alert "Slithering..."
10    super 5
11
12class Horse extends Animal
13  move: ->
14    alert "Galloping..."
15    super 45
16
17sam = new Snake "Sammy the Python"
18tom = new Horse "Tommy the Palomino"
19
20sam.move()
21tom.move()