Skip to content

Instantly share code, notes, and snippets.

@tobyink
Last active January 2, 2016 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobyink/8261347 to your computer and use it in GitHub Desktop.
Save tobyink/8261347 to your computer and use it in GitHub Desktop.
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