From: Trans Date: 2007-12-20T00:42:28+09:00 Subject: Re: Hash#collate On Dec 19, 9:32 am, Nobuyoshi Nakada wrote: > Hi, > > At Wed, 19 Dec 2007 09:05:11 +0900, > Phrogz wrote in [ruby-talk:284104]: > > > 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.) > > {:a=>1, :b=>2 }.update(:a=>3, :b=>4, :c=>5) {|key, *values| values} Woh! Little known is this karate! You can even do: {:a=>1, :b=>2 }.update(:a=>[1,3], :b=>4, :c=>5) {|key, *values| values.flatten.uniq} => {:a=>[1, 3], :b=>[2, 4], :c=>5} T.