Skip to content

Instantly share code, notes, and snippets.

@rightfold

rightfold/.p6 Secret

Created January 16, 2016 21:55
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 rightfold/bd6447b6f03f6b539a80 to your computer and use it in GitHub Desktop.
Save rightfold/bd6447b6f03f6b539a80 to your computer and use it in GitHub Desktop.
class C {
has %!h{Pair};
method m {
%!h{a => 1} = 2;
}
method n {
%!h{a => 2} = 3;
}
method o {
say %!h;
}
method clone(*%twiddles) {
my %h{Pair} = %!h.clone;
my $result = callsame(|%twiddles);
%!h = %h;
$result;
}
}
my $c = C.new();
$c.m;
$c.clone.n;
$c.o; # output: (a => 1) => 2, (a => 2) => 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment