Hi, I wonder what does .clone do and how can I create a deep copy or deep clone of an array?
Reading https://docs.perl6.org/type/Array#method_clone I don't understand what does it do as the example there works without clone as well: suggest I'd need a > my @a = (1, 2, 3) [1 2 3] > my @b = @a; [1 2 3] > @a[1] = 42 42 > @b.append(100) [1 2 3 100] > dd @a Array @a = [1, 42, 3] Nil > dd @b Array @b = [1, 2, 3, 100] Nil On the other hand if I have a deeper data structure, then even .clone does not help. > my @x = {a => 1}, {b => 2}; [{a => 1} {b => 2}] > my @y = @x.clone [{a => 1} {b => 2}] > @x[0]<a> = 42 42 > dd @x Array @x = [{:a(42)}, {:b(2)}] Nil > dd @y Array @y = [{:a(42)}, {:b(2)}] Nil So I wonder what does .clone do and how could I make a deep copy (deep clone) of the whole data structure I have in @x. regards Gabor