You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling .clone on an Array returns a new Array object, but (even
shallow) changes to one affect the other:
my $a = [2, 4, 6];
my $b = @a.clone;
say $a.WHICH; # Array|68924240
say $b.WHICH; # Array|68924304
@a.push(8);
dd $a; # Array $a = $[2, 4, 6, 8]
dd $b; # Array $b = $[2, 4, 6, 8]
IRC comments:
<jnthn> An Array is an object, with a bunch of attributes, once of
which is the actual storage.
<jnthn> I'm guessing Array doesn't have a method clone of its own,
so it does The Default Thing in Mu
<jnthn> Which keeps the storage
<jnthn> It should probably get its own method clone
<jnthn> I thought that had already happened. :
<jnthn> :S
<jnthn> But yeah, it wants fixing. The current behavior is crap.
<timotimo> cue writing spec tests for .clone of pretty much every
single class :)
Migrated from rt.perl.org#129762 (status was 'resolved')
Searchable as RT129762$
The text was updated successfully, but these errors were encountered: