From: Robert Klemme Date: 2008-05-14T06:35:03+09:00 Subject: Re: hash merge On 13.05.2008 18:51, Adam Shelly wrote: > On 5/13/08, Robert Klemme wrote: >> On 13.05.2008 17:14, Yossef Mendelssohn wrote: >>> Thanks for teaching me about Hash#merge with a block, by the way. >>> >> Not really: >> >> irb(main):009:0> h = {1=>2} >> => {1=>2} >> irb(main):010:0> h.merge(10=>20) {|*a| p a} >> => {1=>2, 10=>20} >> irb(main):011:0> >> >> The block is simply ignored. >> > Not really: > > irb(main):010:0> h={1,2} > => {1=>2} > irb(main):011:0> h.merge(10=>20){|*a| p a} > => {1=>2, 10=>20} > irb(main):012:0> h.merge(1=>20){|*a| p a} > [1, 2, 20] > => {1=>nil} > irb(main):013:0> > > The block is only called for matching keys. Amazing. Thank you for the education! I should have looked at the documentation before making a fool of myself... Kind regards robert