Skip to content

Instantly share code, notes, and snippets.

@EvanHahn
Created August 15, 2012 21:41
Show Gist options
  • Save EvanHahn/3363965 to your computer and use it in GitHub Desktop.
Save EvanHahn/3363965 to your computer and use it in GitHub Desktop.
Simple private member functions in CoffeeScript
# There's more complexity to this, as described below:
# http://evanhahn.com/?p=1126
class Person
hello = ->
"hello"
helloWorld: ->
"#{hello()} world!"
me = new Person
me.helloWorld() # => "hello world!"
me.hello() # => TypeError, method not found -- good!
# This code by Evan Hahn (evanhahn.com) is licensed under the Unlicense.
# http://unlicense.org/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment