From: Simon Baird Date: 2006-06-26T13:11:47+09:00 Subject: << for Hash? ------=_Part_31296_31996645.1151295103595 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline class Hash def <<(arg) self.merge!(arg) end end Eg, thing = { :foo => 1, } thing << { :bar => 2, :baz => 3, } thing #=> {:foo=>1, :bar=>2, :baz=>3 } Of course it overwrites existing keys. I think it's a little sexier than thing.merge!({ :bar => 2, :baz => 3, }) or thing[:bar] = 1 thing[:baz] = 3 Is it safe to use this? Is there some good reason why << is not already defined for Hash? Simon (newbie) Ps, my first ruby project: http://tiddlyspot.com/ -- Simon Baird ------=_Part_31296_31996645.1151295103595--