Skip to content

Instantly share code, notes, and snippets.

@ryanbrubaker
Created July 10, 2012 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanbrubaker/3086065 to your computer and use it in GitHub Desktop.
Save ryanbrubaker/3086065 to your computer and use it in GitHub Desktop.
Generated constructors from CoffeeScript class example
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