Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created January 4, 2017 01:08
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 zoffixznet/777579558a0d9c8b4948065f64ec513e to your computer and use it in GitHub Desktop.
Save zoffixznet/777579558a0d9c8b4948065f64ec513e to your computer and use it in GitHub Desktop.
use MONKEY;
augment class BagHash {
method clone2 {
nqp::p6bindattrinvres(
nqp::create(self), self.WHAT, '%!elems',
nqp::getattr(self, self.WHAT,'%!elems').clone
)
}
}
my $a = BagHash.new: <a b c>;
my $b = $a.clone2;
$a<a> = 55; $a<b> = 3; $a<z> = 42; $a<x>++;
dd [$b];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment