Skip to content

Instantly share code, notes, and snippets.

@jakejscott
Created October 2, 2012 04:14
Show Gist options
  • Save jakejscott/3816131 to your computer and use it in GitHub Desktop.
Save jakejscott/3816131 to your computer and use it in GitHub Desktop.
TypeScript vs CoffeeScript
class Animal
constructor: (@name) ->
move: (meters) ->
alert @name + " moved #{meters}m."
class Snake extends Animal
move: ->
alert "Slithering..."
super 5
class Horse extends Animal
move: ->
alert "Galloping..."
super 45
sam = new Snake "Sammy the Python"
tom = new Horse "Tommy the Palomino"
sam.move()
tom.move()
class Animal {
constructor (public name: string) {
}
move (meters: number) {
return alert(this.name + " moved " + meters + " meters")
}
}
class Snake extends Animal {
move() {
alert('slithering')
return super.move(5)
}
}
class Horse extends Animal {
move() {
alert('galloping')
return super.move(45)
}
}
var sam = new Snake("sammy the python");
var tom = new Horse("Tommy the Palomino");
sam.move();
tom.move();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment