Skip to content

Instantly share code, notes, and snippets.

@borisschapira
Created October 3, 2012 08:06
Show Gist options
  • Save borisschapira/3825736 to your computer and use it in GitHub Desktop.
Save borisschapira/3825736 to your computer and use it in GitHub Desktop.
TypeScript Simple Inheritance
class Animal {
constructor(public name) { }
move(meters) {
alert(this.name + " moved " + meters + "m.");
}
}
class Snake extends Animal {
constructor(name) { super(name); }
move() {
alert("Slithering...");
super.move(5);
}
}
var sam = new Snake("Sammy the Python")
sam.move();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment