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
| role Blobject { | |
| } | |
| subset Callback of Callable where { $_.signature.params && $_.signature ~~ :(Blobject --> Bool) }; | |
| my Callback @foo; | |
| class One does Blobject { | |
| } | |
| class Two does Blobject { | |
| } | |
| sub one-sub(One $one) returns Bool { | |
| say "One"; | |
| } | |
| sub two-sub(Two $two) returns Bool { | |
| say "Two"; | |
| } | |
| @foo.push: &one-sub; | |
| @foo.push: &two-sub; | |
| sub run-em(Blobject $blob) { | |
| sub run(|c) { | |
| @foo.grep( -> $v { c ~~ $v.signature })>>.(|c); | |
| } | |
| run($blob); | |
| } | |
| say "Doing one"; | |
| run-em(One.new); | |
| say "Doing two"; | |
| run-em(Two.new); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment