Skip to content

Instantly share code, notes, and snippets.

@brihogan
Created June 22, 2012 19:08
Show Gist options
  • Save brihogan/2974559 to your computer and use it in GitHub Desktop.
Save brihogan/2974559 to your computer and use it in GitHub Desktop.
CoffeeScript: Starter class with class, instance, and private methods
class ClassName
constructor: (attr) ->
@attr = attr
# Private
privateVariable = null
privateMethod = () ->
# Class method
@classMethod : () ->
# Instance method
instanceMethod : () ->
# to access class methods from within an instance
@construtor.classMethod()
# to find name of constructor
@construtor.name # does not work in IE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment