Created
July 27, 2010 16:30
-
-
Save devongovett/492468 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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