-
Notifications
You must be signed in to change notification settings - Fork 576
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
head and tail methods for Mojo::Collection #1360
Conversation
Algorithms adapted from List::Util::PP
👍 Love it! |
Like i said on IRC, it's pretty hard to justify adding so much code for a feature with such limited scope. Are there any good use cases related to |
I guess range() would be sort of a competing feature? #1361
|
range and head/tail would accomplish largely the same things. I'm not sure I can say which is clearer or nicer to use. |
I prefer #1361. |
I just did some tests, and the pair functions in |
Since there have been no changes in some time, and the proposal is kinda complete. I'm just calling for a vote @mojolicious/core! |
The feature seems useful, but i don't think it's useful enough to require so much code. So, i'll be voting neutral. |
Maybe worth mentioning that |
Just as a reminder: #1361 was my alternative, but I closed it since there wasn’t any interest. I still think it’s a good idea to mimic JavaScript though. |
I am in favor of both this and/or #1361. Sorry I'm late to the vote, vacation got in the way |
I think such a feature should exist, but guess I'm neutral to head/tail Sent with GitHawk |
I've changed my vote to 👍, since there is a lot of interest in this functionality and i can't think of a more mojo-ish solution. |
faf5056
to
256c884
Compare
Summary
Methods for Mojo::Collection to create new collections of the beginning or end of the collection.
Algorithms for the methods were adapted from List::Util::PP. We could just delegate to List::Util for XS functions but it would require List::Util 1.50.
Motivation
It can be useful to operate on the beginning or end of the collection during a chain without calculating slice indexes, and resulting in no extra undef elements when going past the original collection indexes.
References
#1350