Frank (>>), Moritz (>): >> Hi, I am new to Perl6 and I'm interested in the feature that allows you to >> add roles to classes. From what I understand you can add a role to an >> object using the "does" keyword. Is there any way you can remove a role or > > No, you cannot remove roles.
However, if you want an un-adorned object later, just use infix:<but>, and keep the original object around. class C { has $.name = "original"; } role W { method name { "wrapped" } } my $original = C.new; { my $wrapped = $original but W; say $wrapped.name; # "wrapped" say $wrapped ~~ W; # True } say $original.name; # "original" say $original ~~ W; # False // Carl