From: Bulat Ziganshin Date: 2002-12-19T00:42:09+09:00 Subject: Re: hash vs. array (dictionary lookup) Hello dblack, Wednesday, December 18, 2002, 6:14:15 PM, you wrote: >> words.each do |word| >> lexicon[word]=0 >> end >> >> Disaster! It took me about 15 seconds to load the >> dictionary. Problem is that the #each method took too >> much time. dcsn> That's really puzzling. I ran the same script in .23s real time, dcsn> using a dict with about 38K words, on a 1.4GHz Pentium. hmm :) but in any case we need more functions to do fast computations with hashes. i propose: Array#to_hash as reverse to Hash#to_a Hash#update(anArray) as equivalent to Hash#update(anArray.to_hash) Hash#update(anArray,value) as equivalent to anArray.each do |word| aHash[word]=value end Hash.new(anArray,value) as equivalent to aHash = {} anArray.each do |word| aHash[word]=value end -- Best regards, Bulat mailto:bulatz@integ.ru