009677
2017/12/08(金) 06:05:43.38ID:DD2Dk6IRstrHash = strArray.each_with_object(Hash.new(0)) { |str, h| h[str] += 1 }
p strHash #=> {"a"=>2, "b"=>1, "c"=>2}
maxCount = strHash.values.max #=> 2
p strHash.select {|k, v| v == maxCount } #=> {"a"=>2, "c"=>2}
key, rassoc を使うと、最初に一致した、1つしか返さない。
p strHash.key(maxCount) #=> "a"
p strHash.rassoc(maxCount) #=> ["a", 2]
>>87
ありがとう。その方法でも出来ますね