Last active
August 29, 2015 14:03
-
-
Save hejrobin/9c7808e26c2b9ee1389e to your computer and use it in GitHub Desktop.
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
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 |
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
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