Created
October 22, 2012 17:56
-
-
Save raganwald/3932975 to your computer and use it in GitHub Desktop.
Discrepancy between CoffeeScript on Node and "Try CoffeeScript"
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
This CoffeeScript: | |
name = 'clyde' | |
do -> | |
"Hello #{name}" for name in ['algernon', 'sabine', 'rupert', 'theodora'] | |
name | |
Complies to this on CoffeeScript under Node: | |
(function() { | |
var name, _i, _len, _ref; | |
name = 'clyde'; | |
_ref = ['algernon', 'sabine', 'rupert', 'theodora']; | |
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
name = _ref[_i]; | |
"Hello " + name; | |
} | |
name; | |
}).call(this); | |
And this on "Try CoffeeScript:" | |
var name; | |
name = 'clyde'; | |
(function() { | |
var _i, _len, _ref, _results; | |
_ref = ['algernon', 'sabine', 'rupert', 'theodora']; | |
_results = []; | |
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
name = _ref[_i]; | |
_results.push("Hello " + name); | |
} | |
return _results; | |
})(); | |
name; | |
Note that in the Node version, "name" is shadowed, but in the Try CoffeeScript version, it isn't. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment