Skip to content

Instantly share code, notes, and snippets.

@cygx

cygx/foo.p6 Secret

Last active November 30, 2016 16:26
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 cygx/a3de36abd398431c6e8513f13bd619e4 to your computer and use it in GitHub Desktop.
Save cygx/a3de36abd398431c6e8513f13bd619e4 to your computer and use it in GitHub Desktop.
multi sub trait_mod:<is>(Method $m, :$accessible!) {
$m.package.WHO{$m.name} = $m;
}
class A {
has $.name = "default";
method !rename($name) is accessible {
$!name = $name;
}
}
class B is A {
method make-me-a-foo {
A::rename(self, "foo");
}
}
my $b = B.new;
say $b.name;
$b.make-me-a-foo;
say $b.name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment