|
|
| go ahead... be a heretic | |
| PerlMonks |
Re: Moose and default valuesby tobyink (Prior) |
| on Feb 20, 2013 at 22:25 UTC ( #1019853=note: print w/ replies, xml ) | Need Help?? |
|
I wrote PerlX::Maybe precisely for this purpose!
As you can see, the maybe keyword is applied at the "consumer side" - i.e. in the code that is using the class. Within the class itself, you could try MooseX::UndefTolerant though that has a major caveat listed in the documentation!
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||