in reply to Re^2: Moose: problem with accessor
in thread Moose: problem with accessor
'=>' is a (slightly special) comma, so
is$self->method => 'changed'
which is$self->method, 'changed'
$self->method(), 'changed'
How can I generally define private methods or attributes?
"Perl doesn't have an infatuation with enforced privacy. It would prefer that you stayed out of its living room because you weren't invited, not because it has a shotgun" — Larry Wall
You can't force something to be private (and it would be useless to do so). However, naming something with a leading "_" is a well known convention to indicate something is private.
Don't I need to define [_set_mode]
No. When you use 'reader', 'writer' and 'accessor', you are asking Moose to create the a function for you.
Keep in mind that «is => 'ro'» is a shortcut for «reader => $att_name» and «is => 'rw'» is a shortcut for «accessor => $att_name».
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Moose: problem with accessor
by saintex (Scribe) on Apr 01, 2011 at 07:38 UTC | |
by ikegami (Patriarch) on Apr 01, 2011 at 13:45 UTC | |
by saintex (Scribe) on Apr 01, 2011 at 14:08 UTC | |
by ikegami (Patriarch) on Apr 01, 2011 at 16:00 UTC |