Created
July 7, 2011 08:27
-
-
Save jakejscott/1069093 to your computer and use it in GitHub Desktop.
Inheritance in CoffeeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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