Rubyのオブジェクト配列にて、各要素の同一属性で同じ値が何個あるかを数えたくなる機会がありました。 例えば class Apple attr_reader :name, :grower def initialize(name, grower) @name = name @grower = grower end end apples = [ Apple.new('シナノゴールド', 'Aさん'), Apple.new('秋映', 'Aさん'), Apple.new('シナノゴールド', 'Bさん'), Apple.new('秋映', 'Cさん'), Apple.new('奥州ロマン', 'Cさ…