From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-06-25T03:31:28+09:00 Subject: Re: Concatenating Hash's On Wed, 25 Jun 2003 01:32:27 +0900, David Landrith wrote: > What is the fastest way to concatenate two hash tables? Have you tried Hash#update ? But you ask about the fastest way... hmm. > expand -t2 b.rb class String def String.rand(size=15) s = String.new size.times do |i| s << (Kernel.rand(93)+33) # ascii range end s end end class Hash def Hash.rand(elements, width) h = Hash.new elements.times do key = String.rand(width) h[key] = Kernel.rand(899)+100 end h end end h1 = Hash.rand(100, 5) h2 = Hash.rand(100, 5) puts "h1=#{h1.size} h2=#{h2.size}" h1.update(h2) puts "h1=#{h1.size} h2=#{h2.size}" > > ruby b.rb h1=100 h2=100 h1=200 h2=100 > Sorry no profiling.. maybe someone else can add it ? -- Simon Strandgaard