Skip to content

Instantly share code, notes, and snippets.

@ChoHag
Created July 6, 2014 06:13
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 ChoHag/adc790bc7ca00b245c62 to your computer and use it in GitHub Desktop.
Save ChoHag/adc790bc7ca00b245c62 to your computer and use it in GitHub Desktop.
moar role/class attributes
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