From: Benoit Daloze Date: 2009-12-27T05:30:51+09:00 Subject: Re: Making a counter for each word's occurrences in a string --0016e65c8846b926ed047ba78bca Content-Type: text/plain; charset=ISO-8859-1 Hi, the "inject" wya to do what you want is: ["sparky", "the", "cat", "sat", "on", "the", "mat"].inject(Hash.new(0)) { |c,w| c[w] +=1; c } => {"sparky"=>1, "the"=>2, "cat"=>1, "sat"=>1, "on"=>1, "mat"=>1} That's kind of very short to write, isn't it ? Ruby is awesome :D 2009/12/26 Phillip Gawlowski > On 26.12.2009 00:21, Ben Ben wrote: > > Thanks Phillip, I got it now. Awesome! Ya, it is going to take me a >> while before I can truly know Ruby and programming in general. >> > > You are welcome. :) > > > -- > Phillip Gawlowski > Wishing everyone a merry Christmas, and happy holidays! > > --0016e65c8846b926ed047ba78bca--