Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Created August 13, 2012 21:28
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 hoelzro/3344225 to your computer and use it in GitHub Desktop.
Save hoelzro/3344225 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
use v6;
role MyRole {
method handle-message($msg) {
my @candidates = self.WALK(:name<handle-command>);
say "self in MyRole.handle-message: {self.gist}";
say "# candidates: {@candidates.elems}";
self.*handle-command($msg);
}
}
role MyOtherRole {
also does MyRole;
method handle-message($msg) {
say 'doing some stuff first';
say "self in MyOtherRole.handle-message: {self.gist}";
self.MyRole::handle-message($msg);
}
multi method handle-command($msg) {
say 'here!';
}
}
my $object = Any.new but MyOtherRole;
$object.handle-message('hello');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment