Skip Menu |

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

Report information
The Basics
Id: 15109
Status: resolved
Worked: 5 min
Priority: 0/
Queue: Class-MethodMaker

People
Owner: fluffy [...] cpan.org
Requestors: mriester [...] gmx.de
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.05
Fixed in: (no value)



Subject: setting empty arrays
hi, maybe this is a feature I don't understand, but this was a source of some hard to find bugs :( if i define an array results like this: array => [qw / results /], $self->results( @empty_array ); seems not work, you have to check before: if (@array == 0) { $self->results_reset; } else { $self->results(@array); } or you have the old values still in results...or do I something stupid here? best regards, markus cpan, 2.05 Mac OSX 10.3 7.9.0 Darwin Kernel Version 7.9.0 This is perl, v5.8.1-RC3 built for darwin-thread-multi-2level
This is not a bug. This is a natural consequence of The Rules. From perldoc Class::MethodMaker::array : * Created by default. This method returns the list of values stored in the slot. If any arguments are provided to this method, they replace the current list contents. In an array context it returns the values as an array and in a scalar context as a reference to an array. Note 'if any' - you are passing in none. There is no way to distinguish passing in an empty array from passing in no arguments (i.e., the default 'return what you have' form). I think you want: $self->results_reset; $self->results(@array);