Skip to content

Instantly share code, notes, and snippets.

Created November 21, 2014 19:39
Show Gist options
  • Save anonymous/08e8d0d5d220543aa89b to your computer and use it in GitHub Desktop.
Save anonymous/08e8d0d5d220543aa89b to your computer and use it in GitHub Desktop.
Animal with flow types
function Animal(name: string, speed: number, focus: number) {
this.name = name;
this.speed = speed || 1;
this.focus = focus || 1;
this.position = 0;
this.run = function() {
if (Math.random() * 10 < this.focus) {
this.position = this.position + this.speed;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment