回答編集履歴

1

sampleの修正

2016/04/07 08:33

投稿

ShoheiUyama
ShoheiUyama

スコア206

test CHANGED
@@ -6,8 +6,14 @@
6
6
 
7
7
  data = [{id: 1, name: "インフルエンザ"}, {id:2, name: "溶連菌感染症"}]
8
8
 
9
- data.select{ | o | o[:name] == "溶連菌感染症" }
9
+ target = data.select{ | o | o[:name] == "溶連菌感染症" }.first
10
10
 
11
- #=> [{:id=>2, :name=>"溶連菌感染症"}]
11
+ #=> {:id=>2, :name=>"溶連菌感染症"}
12
+
13
+
14
+
15
+ target[:name]
16
+
17
+ #=> "溶連菌感染症"
12
18
 
13
19
  ```