Skip to content

Instantly share code, notes, and snippets.

@hejrobin
Last active August 29, 2015 14:03
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 hejrobin/9c7808e26c2b9ee1389e to your computer and use it in GitHub Desktop.
Save hejrobin/9c7808e26c2b9ee1389e to your computer and use it in GitHub Desktop.
class Vessel
constructor: (@type, @name) ->
class Schooner extends Vessel
constructor: (@name) ->
super(@name, @constructor.name)
ship = new Schooner('Wasa')
console.debug ship.type #>> Schooner
console.debug ship.name #>> Wasa
var Schooner, Vessel, ship,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Vessel = (function() {
function Vessel(type, name) {
this.type = type;
this.name = name;
}
return Vessel;
})();
Schooner = (function(_super) {
__extends(Schooner, _super);
function Schooner(name) {
this.name = name;
Schooner.__super__.constructor.call(this, this.name, this.constructor);
}
return Schooner;
})(Vessel);
ship = new Schooner('Wasa');
console.debug(ship.type);
console.debug(ship.name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment