Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: rebuilding lazy Moose attributes

by tobyink (Abbot)
on Aug 20, 2013 at 21:48 UTC ( #1050250=note: print w/replies, xml ) Need Help??


in reply to rebuilding lazy Moose attributes

I tend to use 'ro' attributes as much as possible and thus avoid things like this.

I have a module Trait::Attribute::Derived that offers a bunch of sugar for deriving one attribute from another, but it doesn't offer this feature. Perhaps it should?

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050250]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2018-06-18 05:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (108 votes). Check out past polls.

    Notices?