Array#dup,clone

T

Takaaki Tateishi

$BN)@P$G$9!%(B

$B:#F|$N;~E@$N(Bruby-1.9$B$K$D$$$F$G$9$,!$(B

a = [0,1,2]; p a[0,1].clone

$B$d(B

a = [0,1,2]; a;shift; p a.clone

$B$J$I$,85$N(B[0,1,2]$B$rI=<($9$k$h$&$G$9!%(B

a.shift; a.push(0); p a.clone

$B$J$I$H$9$l$P4|BT$7$?=PNO(B[1,2,0]$B$,F@$i$l$^$9!%(B
 
T

Takaaki Tateishi

Sorry, I have sent the following mail to ruby-talk by mistake.

Takaaki Tateishi said:
...
a = [0,1,2]; p a[0,1].clone ...
a = [0,1,2]; a;shift; p a.clone
...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top