Created
September 18, 2013 16:40
-
-
Save adamloving/6611892 to your computer and use it in GitHub Desktop.
showing inheritance with coffeescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#<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