質問編集履歴
3
間違いを訂正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
配列[
|
1
|
+
配列[5, 2, 4, 6, 1, 3]を深いコピーをしたい
|
test
CHANGED
File without changes
|
2
タイトル
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
配列[1,2,3]を深いコピーをしたい
|
test
CHANGED
File without changes
|
1
タイトル、ソースコードを編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,7 +36,15 @@
|
|
36
36
|
|
37
37
|
def insertionSort(tmp, n)
|
38
38
|
|
39
|
-
ary=tmp.clone
|
39
|
+
# ary=tmp.clone ←変更前
|
40
|
+
|
41
|
+
ary = Marshal.load(Marshal.dump(tmp))
|
42
|
+
|
43
|
+
p [tmp.object_id, ary.object_id]
|
44
|
+
|
45
|
+
p [tmp[0].object_id, ary[0].object_id]
|
46
|
+
|
47
|
+
|
40
48
|
|
41
49
|
(1...n).each{|i|
|
42
50
|
|
@@ -88,6 +96,10 @@
|
|
88
96
|
|
89
97
|
|
90
98
|
|
99
|
+
[13220980, 13220860] # 異なる
|
100
|
+
|
101
|
+
[11, 11] # 同じ
|
102
|
+
|
91
103
|
[5, 2, 4, 6, 1, 3]
|
92
104
|
|
93
105
|
[2, 5, 4, 6, 1, 3]
|