Skip to content

Instantly share code, notes, and snippets.

@devongovett
Created July 27, 2010 16:30
Show Gist options
  • Save devongovett/492468 to your computer and use it in GitHub Desktop.
Save devongovett/492468 to your computer and use it in GitHub Desktop.
# Syntax for private methods in CoffeeScript
class Test
publicMethod: ->
alert @foo
private
foo: "hello world!"
privateMethod ->
"private"
# Would compile into this JavaScript
var Test;
Test = (function() {
var __class = function() {};
__class.prototype.publicMethod = function() {
return alert(__private.foo);
};
var __private = {};
__private.foo = "hello world";
__private.privateMethod = function() {
return "private";
}
return __class;
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment