Files
coffeescript/documentation/coffee/super.coffee
2010-01-10 16:16:59 -05:00

26 lines
392 B
CoffeeScript

Animal: =>
Animal::move: meters =>
alert(this.name + " moved " + meters + "m.")
Snake: name => this.name: name
Snake extends Animal
Snake::move: =>
alert("Slithering...")
super(5)
Horse: name => this.name: name
Horse extends Animal
Horse::move: =>
alert("Galloping...")
super(45)
sam: new Snake("Sammy the Python")
tom: new Horse("Tommy the Palomino")
sam.move()
tom.move()