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
Array.prototype.at compatibility? #148
Comments
Iterators don’t inherently have indexes, and the length can’t be known ahead of time - “at” would have to be like “take” and then “drop”, throwing away all the items up to that “index”. |
The negative index discussion is also in #131 so i'd say this depends on the outcome there. |
Apart from the negative index issue, I dislike using |
Assuming there's no proposal for "number of times next has been called" to become a built-in component of iterator state, it seems like Rather than |
To add onto @bathos’s comment, Clojure uses |
This doesn't provide much value over the proposed alternatives. We should not expand the proposal to include this method. If you would like, you can make a follow-on proposal, but I don't think this method will justify itself. |
I noticed that there is an
.at
method in the Array prototype in stage 3.It seemed kind of useless to me for cases like
[1, 2, 3].at(2)
.But if iterators also implement it, then it'll suddenly make sense for compatibility between the Arrays and Iterators.
Implementing it with negative integers would require going though the entire iterator though.
Also, the iterator would be consumed by this wich might result in unexpected behavior:
The text was updated successfully, but these errors were encountered: