On 10/19/2011 07:38 PM, Alan Haggai Alavi wrote:
> The `wantarray` function can be made use of. It helps in determining
the context.
Thank you for the reply. :-)
Yes.
> sub set {
> my ( $self, @values ) = @_;
> @$self = @values;
> return;
> }
Your set() method doesn't appear to deal with the case:
$o->set(['bozo']); # saves one-item list
Although such could be added easily.
On the argument side, we would probably want to flatten arrayref's
within the argument list:
$o->set('foo', ['bar', 'baz'], ['bozo']); # saves four-item list
But, what about return value(s)? Void? The object? The previous
value(s)? The new value(s)? The number of elements contained after
"set"? Does context matter? There are any number of plausible choices,
which will affect usage. (As an aside, is there such as thing as
methods with multiple return signatures that the caller can pick?)
Rather than re-inventing a wheel that may already exist, I'm wondering
if there is a complete, validated (tested), documented, and supported
solution in Perl or on CPAN.
David
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/