From: Robert Klemme Date: 2008-01-31T19:29:09+09:00 Subject: Re: counting the number of repititions in an array 2008/1/31, Stefano Crocco : > Alle Wednesday 30 January 2008, Adam Akhtar ha scritto: > > res[a] = res[nil] + 1 > > res[a] = res[a] + 1 > > Aside from this, yes, that's how it works Just adding a point because it seems this might not have become totally clear from the thread: the fact that the Hash returns 0 for a missing key is caused by how the Hash is constructed. Normally a hash returns nil for unknown keys: irb(main):001:0> {}[1] => nil irb(main):002:0> Hash.new(0)[1] => 0 irb(main):003:0> Hash.new("foobar")[1] => "foobar" Kind regards robert -- use.inject do |as, often| as.you_can - without end