Created
September 9, 2013 20:17
-
-
Save drinks/6500925 to your computer and use it in GitHub Desktop.
Note to future self: This is how scoping works in 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
class Foo | |
@_cattr = | |
"a": "apple" | |
"b": "banana" | |
"c": "cherry" | |
"d": "dragonfruit" | |
@classCattrGet: -> | |
@_cattr | |
@classCattrSet: (k, v) -> | |
@_cattr[k] = v | |
constructor: (@attr) -> | |
@attr ?= | |
"a": "armadillo" | |
"b": "baboon" | |
"c": "capybara" | |
"d": "dingo" | |
instanceCattrGet: -> | |
@constructor._cattr | |
instanceCattrSet: (k, v) -> | |
@constructor._cattr[k] = v | |
instanceAttrGet: -> | |
@attr | |
instanceAttrSet: (k, v) -> | |
@attr[k] = v | |
window.Foo = Foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment