-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
pass index to forEach #144
Comments
I'd prefer not to require all four arguments on every iterator, it's verbose and would break backwards compatibility. That said, there's no doubt these values are useful. One option would be to use the iterator arity to determine the number of arguments to pass, but this might be unpredictable in some circumstances (eg, fs.readFile). This means that making this change can only be done in the next major version. I'm not against the API change, but I'm afraid you may have to wait a while. |
I totally agree. Meanwhile I have solved this by setting up my own counter. |
+1 for this. |
Why not just add a http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-each_with_index |
Nice suggestion @mratzloff. |
@mratzloff, I also think that makes a lot of sense. If @caolan likes the idea too, I'll implement it and submit a pull request. And then in the next version, if one were to want to unify the two methods, I have one question about the suggestion, though. Could @wingy or anyone else explain to me what the |
@brianmaissy, exactly. |
This is going to be implemented as the more general forEachOf, see #168. This issue should be closed. |
You have missed to pass the index for an element to forEach's iterator function.
Instead of:
it should be:
Better:
I need the index of the value in order to perform various operations.
The text was updated successfully, but these errors were encountered: