more useful options | |
PerlMonks |
Re^3: NonMoose and (clean) inheritanceby tobyink (Canon) |
on Mar 20, 2014 at 22:54 UTC ( [id://1079144]=note: print w/replies, xml ) | Need Help?? |
Builders are just generally a better idea than defaults. (MooseX::Manual::BestPractices even tells you so.) They give you a nice clean way to override the behaviour in subclasses. If you use Moo or MooseX::AttributeShortcuts then you can even do:
... and it will automatically get "translated" to:
... so builders can be just as convenient as defaults are.
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|