Merge pull request #1234 from gzohari/pr-merge-bang-check-type

Add type check in Hash#merge!
This commit is contained in:
Yukihiro "Matz" Matsumoto
2013-05-05 22:49:21 -07:00
+1
View File
@@ -1,5 +1,6 @@
class Hash
def merge!(other, &block)
raise "can't convert argument into Hash" unless other.respond_to?(:to_hash)
if block
other.each_key{|k|
self[k] = (self.has_key?(k))? block.call(k, self[k], other[k]): other[k]