Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^4: Passing arrayref to Moose attributesby tobyink (Canon) |
on Apr 21, 2013 at 08:16 UTC ( [id://1029736]=note: print w/replies, xml ) | Need Help?? |
Under Moose you need to add traits => ["Array"] to the attribute declaration. See Moose::Meta::Attribute::Native::Trait::Array. With Moo you'd use handles_via => "Array" but you'd need to install MooX::HandlesVia first.
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|