From: Trans Date: 2007-12-19T10:29:25+09:00 Subject: Re: Hash#collate On Dec 18, 7:05 pm, Phrogz wrote: > I wanted a method like Hash#update, but that preserved the values from > both the original and argument Hash. A little searching failed to find > it. (I did find that someone somewhere wrote a Hash#collate that's in > my ri docs, but who knows where it came from. Its description appears > not to do at all what I wanted, anyhow.) That's from Facets, probably. But the latest version of Facets renamed it to #mash, for "map hash", which is more descriptive of what it does. (#collate remains an alias for the time being). I like your definition --actually I'm surprised I haven't worked this functionality into Facets yet. I guess I thought #weave took care of it, but that's slightly different b/c it only combines arrays if the value is already an array. So I'm going to add this to Facets. A couple thoughts though... The options don't feel quite right. Maybe it would more versatile to define #uniq on Hash? So then { :a=>1, :b=>2 }.collate( { :a=>1, :b=>3 } ).uniq #=> { :a=>[1], :b=>[2,3] } As for preserving the arrays, I'm not sure. Is that really all that useful? Well, if it is it seems like a better definition for Hash#zip. T.