I am an absolute beginner before Moose, and so far I have read Moosemost of the Cookbook .
There are a few things that I do not get. I created the following package:
package MyRange;
use Moose;
use namespace::autoclean;
has [ 'start', 'end' ] => (
is => 'ro',
isa => 'Int',
required => 1,
);
__PACKAGE__->meta->make_immutable;
1;
Then:
use MyRange;
my $br = MyRange->new(
start => 100,
end => 180
);
Now I can access my fields using, for example, $br->{start}but I also can modify them (though they are "read only"), using, for example $br->{start}=5000. I can also add new keys, for example $br->{xxx}=111.
Did I miss something? Is any object protected? What does it mean ro?
source
share