Created
January 15, 2013 11:30
-
-
Save presidento/4537998 to your computer and use it in GitHub Desktop.
Budapest.js meetup presentation codes (2013-01-14)
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
# 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) |
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
// 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); | |
}); | |
} | |
} |
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
// 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); |
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
// 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