Skip to content
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

[collections] Pass index to partition callback #6288

Open
canac opened this issue Dec 21, 2024 · 0 comments
Open

[collections] Pass index to partition callback #6288

canac opened this issue Dec 21, 2024 · 0 comments

Comments

@canac
Copy link
Contributor

canac commented Dec 21, 2024

Is your feature request related to a problem? Please describe.

I tried to use partition and expected to be able to access the element index like normal array methods, but it isn't passed to the callback.

Describe the solution you'd like

Pass the element index to the partition callback. If the maintainers think this is a good idea, there are other methods in collections that could be passed the index as well. Maybe we should even consider passing in the original array as the third argument to match the signature of most built-in array method callbacks. EDIT: I noticed that most methods accept iterables so passing in the original array does not make sense.

Describe alternatives you've considered

Call .filter twice to partition the array instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant