mhg
By: a guest | Jan 28th, 2010 | Syntax:
Perl | Size: 0.78 KB | Hits: 122 | Expires: Never
#==================== code ===============================
use MooseX::Declare;
class TestMoose {
has p1 => (
is => 'rw',
default => '111',
);
has p3 => (
is => 'rw',
lazy => 1,
default => sub { '333' . $_[0]->p2 },
);
has p2 => (
is => 'rw',
lazy => 1,
default => sub { '222' . $_[0]->p1 },
);
}
my $t = TestMoose->new;
print join ' ', $t->p1, $t->p2, $t->p3, "\n";
$t->p2( 'xxx' );
print join ' ', $t->p1, $t->p2, $t->p3, "\n";
#============================== result ===========================
$ perl testMoose.pl
111 222111 333222111
111 xxx 333222111
# but what i want is:
111 222111 333222111
111 xxx 333xxx