Skip to content

Instantly share code, notes, and snippets.

@AliN11
Last active September 20, 2019 08:23
Show Gist options
  • Save AliN11/ad36e4a6b89d3438eebbdcb0dfa9ad90 to your computer and use it in GitHub Desktop.
Save AliN11/ad36e4a6b89d3438eebbdcb0dfa9ad90 to your computer and use it in GitHub Desktop.
interface LanguageInterface {
sayHello(): string;
}
class Persian implements LanguageInterface {
public sayHello(): string {
return 'درود';
}
}
class French implements LanguageInterface {
public sayHello(): string {
return 'Bonjour';
}
}
class Hello {
public say(lang: LanguageInterface): string {
return lang.sayHello();
}
}
let obj = new Hello;
console.log(obj.say(new Persian));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment