mhg
By: a guest | Jan 28th, 2010 | Syntax:
Perl | Size: 0.68 KB | Hits: 125 | Expires: Never
#use MooseX::Declare;
#class TestMoose {
use Moose;
has color => (
is => 'rw',
default => 'red',
);
has line_color => (
is => 'rw',
lazy => 1,
default => sub { $_[0]->color },
);
has font_color => (
is => 'rw',
lazy => 1,
default => sub { $_[0]->color },
);
#}
my $t = TestMoose->new;
# Should be red red red
print join ' ', $t->color, $t->line_color, $t->font_color, "\n";
$t->color( 'green' );
# Should be green green green
print join ' ', $t->color, $t->line_color, $t->font_color, "\n";