Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CoffeScript in Browser
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8"/>
<title>CoffeScript on browser</title>
<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"
gcd = (x, y) ->
if y is 0 then x else gcd y, x % y
alert gcd 10, 4
<script src="">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.