Last active
December 24, 2015 03:08
-
-
Save cfedde/6734955 to your computer and use it in GitHub Desktop.
What is special about the "name" attribute in this moose module?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Modern::Perl; | |
package A; | |
use Moose; | |
use YAML::XS; | |
has size => ( | |
is => 'ro', | |
default => 4, | |
); | |
has place => ( | |
is => 'ro', | |
default => 'main street', | |
); | |
has name => ( | |
is => 'ro', | |
default => 'bob', | |
); | |
has alt => ( | |
is => 'ro', | |
builder => '_build_aux', | |
); | |
sub _build_aux { | |
my $s = shift; | |
say Dump $s; | |
return reverse $s->name; | |
} | |
package main; | |
my $x = A->new(); | |
say $x->name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment