回答編集履歴
2
修正
test
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
|
29
29
|
**追記**
|
30
30
|
|
31
|
-
Array
|
31
|
+
Array.newでも可
|
32
32
|
|
33
33
|
|
34
34
|
|
1
追記
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
ary = [1,2,3,4,5,6,7,8,9,0]
|
8
8
|
|
9
|
-
|
9
|
+
ary2 = [0..4,0..4].map{|n| ary.slice!(n)}
|
10
10
|
|
11
11
|
```
|
12
12
|
|
@@ -20,6 +20,22 @@
|
|
20
20
|
|
21
21
|
ary = [1,2,3,4,5,6,7,8,9,0]
|
22
22
|
|
23
|
-
|
23
|
+
ary2 = ary.each_slice(5).to_a
|
24
24
|
|
25
25
|
```
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
**追記**
|
30
|
+
|
31
|
+
Array#newでも可
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
|
37
|
+
ary = [1,2,3,4,5,6,7,8,9,0]
|
38
|
+
|
39
|
+
ary2 = Array.new(2){ ary.slice!(0..4) }
|
40
|
+
|
41
|
+
```
|