------ art_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, :bar, :baz }
Of course it overwrites existing keys. I think it's a little sexier than
thing.merge!({
:bar 2,
:baz 3,
})
or
thing[:bar]
thing[:baz]
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 <simon.baird / gmail.com>
------ art_31296_31996645.1151295103595--