Does Perl 6 have a built-in tool to make a deep copy of a nested data structure?
问题 Does Perl 6 have a built-in tool to make a deep copy of a nested data structure? Added example: my %hash_A = ( a => { aa => [ 1, 2, 3, 4, 5 ], bb => { aaa => 1, bbb => 2 }, }, ); my %hash_B = %hash_A; #my %hash_B = %hash_A.clone; # same result %hash_B<a><aa>[2] = 735; say %hash_A<a><aa>[2]; # says "735" but would like get "3" 回答1: my %A = ( a => { aa => [ 1, 2, 3, 4, 5 ], bb => { aaa => 1, bbb => 2 }, }, ); my %B = %A.deepmap(-> $c is copy {$c}); # make sure we get a new container instead of