Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 123961
Status: open
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: AARONRP [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: native array slice method
The "get" method of the native array trait allows only one value at a time to be returned. It would be nice if there were a "slice" method that allowed several values by index to be returned. Or, alternatively, extend the "get" method to accept multiple values. Perhaps not the _most_ important issue ever, but it seemed like an odd omission. And in general, thanks for Moose, it's really helpful!
On 2017-12-28 14:27:31, AARONRP wrote: Show quoted text
> The "get" method of the native array trait allows only one value at a > time to be returned. It would be nice if there were a "slice" method > that allowed several values by index to be returned. Or, > alternatively, extend the "get" method to accept multiple values. > > Perhaps not the _most_ important issue ever, but it seemed like an odd > omission. > > And in general, thanks for Moose, it's really helpful!
I think some sort of "multi-get" operation could make sense. We wouldn't want to extend the existing "get" because that leads to context issues like this: Foo->new( size => $obj->get(1, 2) ); # list context So we'd want a new method that is documented to always potentially return a list. Separately, I also note that we don't offer a wrapper for Perl's built-in "slice", which seems like an omission. But you wouldn't want to use it for multi-get, since it also allows mutation of the array.