in reply to Moose Accessor Question
Arghhh... Your code doesn't work! I fixed it as follows and there's no behavior you described:
package Wibble; use Moose; has 'thingies' => ( is => 'rw', isa => 'ArrayRef' ); package main; my $w = Wibble->new( thingies => [ 'this', 'that' ] ); print join( ", ", @{ $w->thingies() } ) . "\n"; $w->thingies('another'); print join( ", ", @{ $w->thingies() } ) . "\n"; __END__ this, that Attribute (thingies) does not pass the type constraint because: Valida +tion failed for 'ArrayRef' failed with value another at (eval 69) lin +e 7 Wibble::thingies('Wibble=HASH(0x1274b38)', 'another') called at 74 +2018.pl line 10
Update: and if you use $w->thingies(['another']); the last statement prints just 'another'.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Moose Accessor Question
by pileofrogs (Priest) on Feb 06, 2009 at 23:36 UTC | |
by zwon (Abbot) on Feb 07, 2009 at 17:41 UTC |