Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Making 'all' the attributes read only by default (Moo)

by blindluke (Hermit)
on Jan 22, 2015 at 21:34 UTC ( [id://1114189]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    package Foo {
        use Moo;
    ...
        has 'attr_B' => ( is => 'ro', default => sub { 'B' } );
        has 'attr_C' => ( is => 'ro', isa => sub { die unless $_[0] > 0 } 
    +);
    }
    
  2. or download this
    package Foo {
        use Moo;
    ...
        has 'attr_B' => ( default => sub { 'B' } );
        has 'attr_C' => ( isa => sub { die unless $_[0] > 0 } );
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1114189]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-23 15:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found