Created
March 15, 2011 17:29
-
-
Save thelinuxlich/871090 to your computer and use it in GitHub Desktop.
This file contains 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
class @Animal | |
constructor: () -> | |
@id = "" | |
@urls: [] | |
@print: -> | |
console.log @urls | |
printInternal: -> | |
console.log(@urls) | |
class @Dog extends @Animal | |
@urls: ["aaa"] | |
class @Cat extends @Animal | |
@urls: ["bbb"] | |
class @Rat extends @Animal | |
# this prints ["aaa"] | |
@Dog.print() | |
# this prints ["bbb"] | |
@Cat.print() | |
# this prints an empty array | |
@Rat.print() | |
d = new @Dog() | |
# this doesn't print ["aaa"] :( | |
d.printInternal() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment