Last active
January 11, 2019 10:53
-
-
Save marcus-sa/c8efdd7ed61733eebde6fe677bde4328 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 IBird { | |
canFly(): boolean; | |
} | |
class Crow implements IBird { | |
public canFly() { | |
return true; | |
} | |
} | |
class Goose implements IBird { | |
public canFly() { | |
return true; | |
} | |
} | |
class App { | |
constructor(birds: IBird[]) { | |
birds.forEach(bird => { | |
const { name } = bird.constructor; | |
if (bird.canFly()) { | |
console.log(name + " can fly"); | |
} else { | |
console.log(name + " can't fly"); | |
} | |
}); | |
} | |
} | |
const container = new Container(); | |
container.bind(InterfaceSymbol<IBird>(), [Crow, Goose]); | |
container.startBootstrap(App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment