Created
August 13, 2012 21:28
-
-
Save hoelzro/3344225 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
#!/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