Last active
January 2, 2016 06:09
-
-
Save tobyink/8261347 to your computer and use it in GitHub Desktop.
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 Moops 0.029; | |
class Person 0.001 | |
{ | |
lexical_has name => ( | |
isa => Str, | |
reader => \(my $_get_name), | |
writer => \(my $_set_name), | |
); | |
method assume_name (Str $name) | |
{ | |
$self->$_set_name($name); | |
say "OK, that's my new name."; | |
} | |
method my $_introduction (Str $template = "Hello, I am %s.") | |
{ | |
return sprintf($template, $self->$_get_name); | |
} | |
method introduce_yourself () | |
{ | |
say $self->$_introduction(); | |
} | |
} | |
my $bob = Person->new; | |
$bob->assume_name("Robert"); | |
$bob->introduce_yourself(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment