From: Robert Klemme Date: 2003-06-26T00:44:04+09:00 Subject: Re: Concatenating Hash's "Simon Strandgaard" <0bz63fz3m1qt3001@sneakemail.com> schrieb im Newsbeitrag news:pan.2003.06.25.08.56.32.933291@sneakemail.com... > On Wed, 25 Jun 2003 10:45:02 +0200, Robert Klemme wrote: > > > > def hash_join(h1,h2); h1.dup.update(h2); end > > > > you could also do > > > > class Hash; def +(o); dup.update(o); end; end > > > > h1={1,2,3,4} > > h2={"a","b"} > > h1 + h2 # => {"a"=>"b", 1=>2, 3=>4} > > > If your hash-tables has differents sizes, I suppose that it will be > fastest to merge the smallest into the biggest. You mean class Hash; def +(o); if size >= o.size then dup.update(o); else o+self; end; end; end ? robert