Mo supports chained accessors

with the help of ingydotnet++ valuable suggestions, Mo now has the option to chain accessors:

package ChainedAccessors;
use Mo qw/chain/;

has 'first'  => (chain => 1);
has 'second' => (chain => 1);


package main;

$f = ChainedAccessors->new;

$f->first(1)->second(2);

$f->first;  # 1
$f->second; # 2

thanks also for the feedback in response to my previous blog post

5 Comments

Looks handy, although having to specify chain when loading Mo and also for each attribute seems a bit odd - is that for technical reasons?

(also, looks like my comment on the previous post never made it through, wasn't particularly important though!)

Looks handy, although having to specify chain when loading Mo and also for each attribute seems a bit odd - is that for technical reasons?

(also, looks like my comment on the previous post never made it through, wasn't particularly important though!)

That seems like the kind of feature that justifies the eventual creation of M.pm

About Forward Ever

user-pic I blog about Perl.