From: Fleck Jean-Julien Date: 2009-10-05T18:43:23+09:00 Subject: Re: Count the number of times an element occurs in an array Hello, 2009/10/5 Jim Burgess : > Hi, > > I need to count the number of times an element occurs in an array. Using Enumerable.count should do the trick: a = ["a", "b", "a", "b", "b"] a.uniq.each do |elem| puts "#{elem}\t#{a.count(elem)}" end Produces: a 2 b 3 Cheers, -- JJ Fleck PCSI1 Lycée Kléber