From: Simon Baird Date: 2006-06-27T08:44:14+09:00 Subject: Re: << for Hash? ------=_Part_13224_619102.1151365450330 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 6/26/06, Matthew Harris wrote: > I like Michael's solution. > > The {}'s are not needed, as long as the hash is the only or last > argument to a method. > > {:a => 1, :b => 2}.merge(:c => 3, :d => 4) > #=> {:a => 1, :b => 2, :c => 3, :d => 4) > I noticed this: class Hash def <<(arg) self.merge!(arg) end end x = { :a => 1 } x.<< :f => 1, :g => 1 # works x << :h => 1, :i => 1 # syntax error Is there a way to make the above work? I don't care really since I think the following is clearer: x << { :h => 1, :i => 1 } # my preferred Cheers, Simon. -- Simon Baird ------=_Part_13224_619102.1151365450330--