Skip to content

@presidento /class-sample.coffee
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Budapest.js meetup presentation codes (2013-01-14)
# CoffeeScript code
class Greeter
constructor: (@greeting) ->
greet: (name) ->
console.log @greeting + name
class AllGreeter extends Greeter
constructor: (greeting, @names) ->
super greeting
greetAll: () ->
@names.forEach (name) =>
@greet(name)
// TypeScript code
class Greeter {
constructor(public greeting: string) {}
greet(name: string) {
console.log(this.greeting + name);
}
}
class AllGreeter extends Greeter {
constructor(greeting: string, public names : string[]) {
super(greeting)
}
greetAll() {
this.names.forEach((name) => {
this.greet(name);
});
}
}
// compiled CoffeeScript code (with unified indentation)
var __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; };
var Greeter = (function () {
function Greeter(greeting) {
this.greeting = greeting;
}
Greeter.prototype.greet = function (name) {
return console.log(this.greeting + name);
};
return Greeter;
})();
var AllGreeter = (function (_super) {
__extends(AllGreeter, _super);
function AllGreeter(greeting, names) {
this.names = names;
AllGreeter.__super__.constructor.call(this, greeting);
}
AllGreeter.prototype.greetAll = function () {
var _this = this;
return this.names.forEach(function (name) {
return _this.greet(name);
});
};
return AllGreeter;
})(Greeter);
// compiled TypeScript code (with unified indentation)
var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Greeter = (function () {
function Greeter(greeting) {
this.greeting = greeting;
}
Greeter.prototype.greet = function (name) {
console.log(this.greeting + name);
};
return Greeter;
})();
var AllGreeter = (function (_super) {
__extends(AllGreeter, _super);
function AllGreeter(greeting, names) {
this.names = names;
_super.call(this, greeting);
}
AllGreeter.prototype.greetAll = function () {
var _this = this;
this.names.forEach(function (name) {
_this.greet(name);
});
};
return AllGreeter;
})(Greeter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.