Skip to content

Instantly share code, notes, and snippets.

@drinks
Created September 9, 2013 20:17
Show Gist options
  • Save drinks/6500925 to your computer and use it in GitHub Desktop.
Save drinks/6500925 to your computer and use it in GitHub Desktop.
Note to future self: This is how scoping works in coffeescript.
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