Skip Menu |

This queue is for tickets about the Class-MakeMethods CPAN distribution.

Report information
The Basics
Id: 45651
Status: open
Priority: 0/
Queue: Class-MakeMethods

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

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



Subject: can we have "push" and "shift" on arrays?
How hard would it be to provide common array methods like "push", "pop", etc. for array items? E.g. use Class::MakeMethods::Standard::Hash(array => 'aaa'); ... $self->push_aaa(qw( elem1 elem2 )); $elem = $self->shift_aaa; Or something like that? If my question doesn't make sense, I apologize. I am a very beginning user of this module but I don't see this basic functionality is provided.
From: simonm [...] cavalletto.org
On Sat May 02 16:36:44 2009, MTHURN wrote: Show quoted text
> How hard would it be to provide common array methods like "push", "pop", > etc. for array items? E.g. > > use Class::MakeMethods::Standard::Hash(array => 'aaa'); > ... > $self->push_aaa(qw( elem1 elem2 )); > $elem = $self->shift_aaa;
This is implemented now -- you just switch from the Standard:: implementations to Template::*. use Class::MakeMethods::Template::Hash(array => 'aaa'); ... $self->push_aaa(qw( elem1 elem2 )); $elem = $self->shift_aaa; Another example is shown here: http://search.cpan.org/~evo/Class- MakeMethods/MakeMethods/Docs/Examples.pod#Reference_Accessor_and_Helper_Methods This type of feature is not implemented in the Standard::* libraries to keep it simple, but by all means, switch to the more powerful version if you want the helper methods and other "extras". -Simon
Thank you. However it appears that the Template modules are not a drop-in replacement for the Standard, because some functionality is lost -- namely, the ability to grab the entire array my @a = $self->aaa();