回答編集履歴
2
修正
test
CHANGED
@@ -1,16 +1,4 @@
|
|
1
1
|
```Ruby
|
2
|
-
|
3
|
-
class MyArray < Array
|
4
|
-
|
5
|
-
def <<(value)
|
6
|
-
|
7
|
-
self.push(value)
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
2
|
|
15
3
|
1.upto(100) do |i|
|
16
4
|
|
@@ -20,7 +8,7 @@
|
|
20
8
|
|
21
9
|
if res.nil?
|
22
10
|
|
23
|
-
self.instance_variable_set("@array#{i}",
|
11
|
+
self.instance_variable_set("@array#{i}", [])
|
24
12
|
|
25
13
|
end
|
26
14
|
|
@@ -38,19 +26,15 @@
|
|
38
26
|
|
39
27
|
|
40
28
|
|
41
|
-
array21
|
29
|
+
p array21
|
42
30
|
|
43
|
-
array61
|
31
|
+
p array61
|
44
32
|
|
45
|
-
(
|
33
|
+
(1..3).each { |e| array21 << e }
|
46
34
|
|
47
|
-
|
35
|
+
(4..6).each { |e| array61 << e }
|
48
36
|
|
49
37
|
p array21.zip(array61).to_h
|
50
|
-
|
51
|
-
p array61 << array71
|
52
|
-
|
53
|
-
|
54
38
|
|
55
39
|
|
56
40
|
|
1
修正
test
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
```Ruby
|
2
|
+
|
3
|
+
class MyArray < Array
|
4
|
+
|
5
|
+
def <<(value)
|
6
|
+
|
7
|
+
self.push(value)
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
2
14
|
|
3
15
|
1.upto(100) do |i|
|
4
16
|
|
@@ -6,7 +18,13 @@
|
|
6
18
|
|
7
19
|
res = self.instance_variable_get("@array#{i}")
|
8
20
|
|
9
|
-
res.nil?
|
21
|
+
if res.nil?
|
22
|
+
|
23
|
+
self.instance_variable_set("@array#{i}", MyArray.new)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
self.instance_variable_get("@array#{i}")
|
10
28
|
|
11
29
|
end
|
12
30
|
|
@@ -24,9 +42,13 @@
|
|
24
42
|
|
25
43
|
array61 = [4, 5, 6]
|
26
44
|
|
27
|
-
|
45
|
+
(7..9).each { |i| array71 << i }
|
46
|
+
|
47
|
+
p array21 + array61
|
28
48
|
|
29
49
|
p array21.zip(array61).to_h
|
50
|
+
|
51
|
+
p array61 << array71
|
30
52
|
|
31
53
|
|
32
54
|
|