Created
July 10, 2012 20:32
-
-
Save ryanbrubaker/3086065 to your computer and use it in GitHub Desktop.
Generated constructors from CoffeeScript class example
This file contains 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
Animal = (function() | |
{ | |
function Animal(name) | |
{ | |
this.name = name; | |
} | |
Animal.prototype.move = function(meters) | |
{ | |
return alert(this.name + (" moved " + meters + "m.")); | |
}; | |
return Animal; | |
})(); | |
Snake = (function(_super) | |
{ | |
__extends(Snake, _super); | |
function Snake() | |
{ | |
return Snake.__super__.constructor.apply(this, arguments); | |
} | |
Snake.prototype.move = function() | |
{ | |
alert("Slithering..."); | |
return Snake.__super__.move.call(this, 5); | |
}; | |
return Snake; | |
})(Animal); | |
sam = new Snake("Sammy the Python"); | |
sam.move(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment