From: Jim Burgess Date: 2009-10-05T21:22:59+09:00 Subject: Re: Count the number of times an element occurs in an array Cheers for the replies, they are certainly very interesting and I will work through all of them. However, now I'm having weird problem. When I run the following on Linux: a = ["a", "b", "a", "b", "b"] a.uniq.each do |elem| puts "#{elem}\t#{a.count(elem)}" end I get the expected output : a 2 b 3 But when I run exactly the same code on Windows I get: undefined method `count' for ["a", "b", "a", "b", "b"]:Array (NoMethodError) ruby -v (Linux): ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux] ruby -v (Windows): ruby 1.8.6 (2009-09-24 patchlevel 111) [i386-mswin32] Does anyone have an idea why this could be happening. I have tried searching for a solution with Google, but could find nothing helpful. -- Posted via http://www.ruby-forum.com/.