-
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
for
comprehension doesn't works with return
and yield
#3357
Comments
It will compile (at least on 1.7.1) if you align the last line ( You probably want:
Or: This relies on CoffeeScript's implicit returns combined with the [almost]-everything-is-an-expression philosophy - the explicit, non-idiomatic equivalent would be (Of course, unless you plan on actually operating on the elements in Edit: You probably meant the prefix form of the comprehension; the approach is the same, though:
|
Exactly, I want to return another list after doing some modifications to
It's not a "new line" after return. There's an indentation, it's part of the loop, not a "new line".
Yes, and as soon as it works with implicit |
Pragmatically speaking:
In case you're raising a language-design question: I'll let others who know more about the language answer, but I can say this: at the very least there is ambiguity: (As an aside: maybe you're fully aware of this, but note that |
@mklement0: When followed by a block, the meaning changes. Also consider |
@michaelficarra: Thanks for the tips - very handy.
Can you please elaborate? Are you saying that what @alexeyPetrushin is trying to do should work? |
Yes, which is why I reopened this issue. No parentheses should be needed when a block follows the comprehension header. These examples all work in CoffeeScriptRedux. |
@michaelficarra: Got it, thanks. So |
Yep. |
Related: |
That's a different issue. We shouldn't be generating invalid JS. |
for
comprehension doesn't works with return
for
comprehension doesn't works with return
and yield
This code doesn't compiles
The text was updated successfully, but these errors were encountered: