Skip to content

Instantly share code, notes, and snippets.

@jakejscott
Created July 7, 2011 08:27
Show Gist options
  • Save jakejscott/1069093 to your computer and use it in GitHub Desktop.
Save jakejscott/1069093 to your computer and use it in GitHub Desktop.
Inheritance in CoffeeScript
window.Dish = class Dish
constructor: (rawDescription="") ->
@title = rawDescription.match(/([^$]+)/)?[1]?.trim()
hello: ->
alert('I am a yummy ' + @title)
window.YummyDish = class YummyDish extends Dish
hello: ->
alert('I am a yummy dish ' + @title)
super()
new Dish("Sirloin steak $18.99").hello()
new YummyDish("Creamy Pasta $29.99").hello()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment