-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using for..of with do, doesn't behave as expected (newbie disclaimer) #4118
Comments
I'm not sure what you mean. The fact that |
what I'm saying, is I would expect the original coffee code to compile to this:
|
Those are global variables. They shouldn't be. What's the issue? |
There is no relationship between the // do (key, val) -> makeGetter key, get: -> return val
(function(key, val) {
return makeGetter(key, {
get: function() {
return val;
}
});
})(key, val); Notice that You can rewrite your code to: for own key, symbol of LEVELS
do (key, symbol) -> makeGetter key, get: -> return symbol
# OR, more clearly?
for own key, symbol of LEVELS then do (key, symbol) ->
makeGetter key, get: -> symbol |
Okay, well I figured it out, and there's no need to dwell on the issue. Perhaps it's more productive to figure out if this is clearly described in the language guide? But I guess it's just as easy to look at the generated code. |
See #2518 for some discussion about |
I'm new to using coffeescript, so thanks for this first of all. It's got it's nuances, but overall a beautiful language.
I would like to point out I've had some troubling experience with the way the do operator works
consider:
That compiles to:
(Which wouldn't work in this case)
where I would actually expect the parameters named after the do operator, to only be relevant to the names they're given in the function definition.
The actual behavior would be more clear if the names weren't required to look like a function parameter definition, but could be passed without parens as if they were arguments to the do op.
The text was updated successfully, but these errors were encountered: