Skip to content

Instantly share code, notes, and snippets.

@hyperfocusaurus
Forked from anonymous/private.coffee
Last active August 29, 2015 14:09
Show Gist options
  • Save hyperfocusaurus/0b75d1f24771a80a4c88 to your computer and use it in GitHub Desktop.
Save hyperfocusaurus/0b75d1f24771a80a4c88 to your computer and use it in GitHub Desktop.
class Foo
privateBar = "bar"
constructor: () ->
getPrivateBar = _.bind getPrivateBar, @
getPrivateBar = () ->
privateBar
publicBar: () ->
getPrivateBar()
@hyperfocusaurus
Copy link
Author

Updated to demonstrate the use of _.bind to bind private functions to the instance pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment