回答編集履歴
2
修正
test
CHANGED
@@ -4,8 +4,16 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
p str.split('|').map{|e| e.split(':')}.to_h
|
7
|
+
p str.split('|').map { |e| e.split(': ') }.to_h
|
8
8
|
|
9
9
|
```
|
10
10
|
|
11
11
|
考えてみました。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
参考にしたページ
|
16
|
+
|
17
|
+
[[Ruby] each_with_objectもmapも使わずにto_hだけで配列をハッシュに変換する](https://techracho.bpsinc.jp/hachi8833/2016_11_30/29584)
|
18
|
+
|
19
|
+
[配列からハッシュを作成する](http://www.rubylife.jp/ini/hash_class/index7.html)
|
1
修正
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
p str.split('|').map{|e| e.split(':
|
7
|
+
p str.split('|').map{|e| e.split(':')}.to_h
|
8
8
|
|
9
9
|
```
|
10
10
|
|