Created
April 14, 2011 12:36
-
-
Save tomekwojcik/919386 to your computer and use it in GitHub Desktop.
Not so cool at all.
This file contains 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
CoffeeScript: | |
end = -> | |
test = (x) -> | |
console.log(x) | |
end() | |
test2 = (x, y) -> | |
x + y | |
end() | |
JavaScript: | |
(function() { | |
var end, test; | |
end = function() {}; | |
test = function(x) { | |
console.log(x); | |
return end; | |
}; | |
}).call(this); | |
Problems: | |
1. Ugly, | |
2. You'd lose the "return last statement" feature of CoffeScript. end() returns undefined and that's a problem in test2. | |
Solution: | |
Add a noop keyword so CoffeScript code would be: | |
test2 = (x, y) -> | |
x + y | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment