Skip to content

Instantly share code, notes, and snippets.

@willscripted
Last active December 28, 2015 16:19
Show Gist options
  • Save willscripted/7528658 to your computer and use it in GitHub Desktop.
Save willscripted/7528658 to your computer and use it in GitHub Desktop.
Coffee - adventure with private method binding
class Thang
class Thing extends Thang
# isPrivate must exist above use in initialize
isPrivate = ->
return @things
initialize: ->
@things = true
# CS will assume local var if isPrivate is declared below this fn
isPrivate = isPrivate.bind(this) # werks
isAlsoPrivate = isAlsoPrivate.bind(this) # does not work, isAlsoPrivate undefined
isAlsoAlsoPrivate() # method would exist if reachable
isAlsoPrivate = ->
@things
isAlsoAlsoPrivate = ->
@things
stuff: ->
isPrivate()
x = new Thing
x.initialize()
alert x.stuff()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment