mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #4031 from i110/i110/hash_default
let Hash#merge keep ifnone value
This commit is contained in:
+1
-2
@@ -179,10 +179,9 @@ class Hash
|
||||
#
|
||||
# ISO 15.2.13.4.22
|
||||
def merge(other, &block)
|
||||
h = {}
|
||||
raise TypeError, "can't convert argument into Hash" unless other.respond_to?(:to_hash)
|
||||
other = other.to_hash
|
||||
self.each_key{|k| h[k] = self[k]}
|
||||
h = self.dup
|
||||
if block
|
||||
other.each_key{|k|
|
||||
h[k] = (self.has_key?(k))? block.call(k, self[k], other[k]): other[k]
|
||||
|
||||
Reference in New Issue
Block a user