add type check in Hash#merge!

This commit is contained in:
Gilad Zohari
2013-05-03 23:36:02 +03:00
parent 7d134d941b
commit 17eef070da
+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]