Created
August 3, 2018 15:55
-
-
Save avermeulen/26cff48a42120023f0abe2dd79fd4bd0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| interface Language { | |
| greet(name: string) : string | |
| //shout(name: string) : string | |
| } | |
| function English () : Language { | |
| function greet (name) { | |
| return 'Hello, ' + name; | |
| } | |
| return { | |
| greet | |
| }; | |
| } | |
| function Xhosa () : Language { | |
| function greet (name) { | |
| return 'Molo, ' + name; | |
| } | |
| return { | |
| greet | |
| }; | |
| } | |
| function Afrikaans() : Language { | |
| function greet(name) { | |
| return "Goeie more, " + name; | |
| } | |
| return { | |
| greet | |
| } | |
| } | |
| function Person (language: Language) { | |
| function greet (name) { | |
| return language.greet(name); | |
| } | |
| return { | |
| greet | |
| }; | |
| } | |
| let person = Person({ | |
| greet : function(name) { | |
| return "Yo, " + name; | |
| } | |
| }); | |
| console.log(person.greet('Andre')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment