-
-
Save MattOates/dd32fb60f5d1e9e2eb64 to your computer and use it in GitHub Desktop.
Playing with delegation in perl6
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; | |
class Mouth { | |
has @.vocab; | |
method speak { | |
say @!vocab.pick; | |
} | |
} | |
class Cat { | |
has $!mouth handles :meow<speak> = Mouth.new(vocab => <ROAR! meow>); | |
} | |
my $test = Cat.new; | |
$test.meow; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment