Instantly share code, notes, and snippets.

Embed
What would you like to do?
CoffeScript in Browser
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>CoffeScript on browser</title>
</head>
<body>
<script type="text/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 Palamino"
sam.move()
tom.move()
gcd = (x, y) ->
if y is 0 then x else gcd y, x % y
alert gcd 10, 4
</script>
<script src="https://cdn.rawgit.com/jashkenas/coffeescript/1.11.1/extras/coffee-script.js">
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment