Created
July 6, 2014 06:13
-
-
Save ChoHag/adc790bc7ca00b245c62 to your computer and use it in GitHub Desktop.
moar role/class attributes
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 foo { | |
my @.bar; | |
method addbar (*@new) { @.bar.push(@new) } | |
} | |
class bar does foo { | |
method BUILD { self.addbar('bar') } | |
} | |
class baz does foo { | |
method BUILD { self.addbar('baz') } | |
} | |
say bar.new.bar; | |
say '-'; | |
say baz.new.bar; | |
say '-'; | |
----- | |
[mking@eldrin ~/src]$ perl6-m rolewtf.pl | |
bar | |
- | |
bar baz | |
- | |
[mking@eldrin ~/src]$ perl6-j rolewtf.pl | |
bar | |
- | |
baz | |
- | |
[mking@eldrin ~/src]$ perl6-p rolewtf.pl | |
bar | |
- | |
baz | |
- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment