Skip to content

Instantly share code, notes, and snippets.

@presidento
Created January 15, 2013 11:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save presidento/4537998 to your computer and use it in GitHub Desktop.
Save presidento/4537998 to your computer and use it in GitHub Desktop.
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