From: Joseph McDonald Date: 2002-09-10T07:41:47+09:00 Subject: Re: How best to histogram words? aq> I want to count the occurrence of specific words. In the past I've aq> used a hash as shown below. Is there a better way? I don't know which aq> words will occur, otherwise I'd just preinitialize the hash to all aq> zeros. try: wordcnt = Hash.new(0) while l = gets.split.each do |w| wordcnt[w] += 1 end puts wordcnt regards, -joe