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

    Sorry, I must not have been clear. It's not supposed to be an example of working code. It's an example of how I'd like my code to be able to work.

    I assume I'd have to do something in the definition of Wibble to make it work and that something is what I'm looking for.

      Ooops... My bad, misread.