Skip to content

Commit e0a4e7e

Browse files
committed
Deletes the second alternative for deep cloning
Which does not actually work. A small reflow here and there. Closes #2627
1 parent 22a1cb5 commit e0a4e7e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

doc/Type/Mu.pod6

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,17 @@ with my $o2 = $o1.clone {
245245
}
246246
247247
# Hash and Array attribute modifications in clone appear in original as well:
248-
say $o1; # OUTPUT: «Foo.new(foo => 42, bar => ["Z", "Y"], baz => {:X("W"), :Z("Y")}, …␤»
249-
say $o2; # OUTPUT: «Foo.new(foo => 70, bar => ["Z", "Y"], baz => {:X("W"), :Z("Y")}, …␤»
248+
say $o1;
249+
# OUTPUT: «Foo.new(foo => 42, bar => ["Z", "Y"], baz => {:X("W"), :Z("Y")}, …␤»
250+
say $o2;
251+
# OUTPUT: «Foo.new(foo => 70, bar => ["Z", "Y"], baz => {:X("W"), :Z("Y")}, …␤»
250252
$o1.boo.(); # OUTPUT: «Hi␤»
251253
$o2.boo.(); # OUTPUT: «Bye␤»
252254
=end code
253255
254256
To clone those, you could implement your own C<.clone> that clones the
255257
appropriate attributes and passes the new values to C<Mu.clone>, for example,
256-
via L«C<nextwith>|/language/functions#sub_nextwith». Alternatively,
257-
your own C<.clone> could clone self first
258-
(using C<self.Mu::clone> or L«C<callsame>|/language/functions#sub_callsame»)
259-
and then manipulate the clone as needed, before returning it.
258+
via L«C<nextwith>|/language/functions#sub_nextwith».
260259
261260
=begin code
262261
class Bar {
@@ -266,7 +265,7 @@ class Bar {
266265
method clone { nextwith :foo(@!foo.clone), :bar(%!bar.clone), |%_ }
267266
}
268267
269-
my $o1 = Bar.new;
268+
my $o1 = Bar.new( :42quux );
270269
with my $o2 = $o1.clone {
271270
.foo = <Z Y>;
272271
.bar = <Z Y X W>;

0 commit comments

Comments
 (0)