From: goodieboy Date: 2008-02-16T00:56:44+09:00 Subject: Re: recursive merge for hash Thanks. But the only problem with that is, the overriding hash will completely destroy *all* of the values in the original. So if I want to just override one value, I get only one value. In this example, "Sam" is lost: first = { :data=>{ :name=>{ :first=>'Sam', :middle=>'I', :last=>'am' } } } second={ :data=>{ :name=>{ :middle=>'you', :last=>'are' } } } all_new = first.merge(second) puts all_new.inspect On Feb 15, 10:47 am, "Farrel Lifson" wrote: > On 15/02/2008, goodieboy wrote: > > > Hi, > > > Does anyone know of a good recursive merge method for Hashes? I'd like > > to be able to do something like: > > > new_h = first.merge_r(second).merge_r(third) > > > ... everything would be a copy, and hashes applied later in the > > sequence override the previous finally, returning a completely new > > hash... is there something out there like this? > > new_h = first.merge(second).merge(third) > > Farrel