Skip to content

Instantly share code, notes, and snippets.

@adamloving
Created September 18, 2013 16:40
Show Gist options
  • Save adamloving/6611892 to your computer and use it in GitHub Desktop.
Save adamloving/6611892 to your computer and use it in GitHub Desktop.
showing inheritance with coffeescript
#<html>
#<head>
#<script src="http://codeorigin.jquery.com/jquery-1.10.2.min.js"></script>
#<script src="example.js"></script>
#</head>
#<body>
#<h1>Example</h1>
#</body>
#</html>
class Vehicle
# @build: (wheels = 4) ->
# if wheels
constructor: ->
console.log 'vehicle constructor'
class MotorCycle extends Vehicle
constructor: ->
@wheels = 2
super()
class Car extends Vehicle
constructor: ->
@wheels = 4
super()
drive: ->
console.log 'Car driving!', @
myCar = new Car();
$(document).ready(myCar.drive)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment