mruby-hash-ext/hash.rb (merge!): takes multiple arguments.
MODIFY
mrbgems/mruby-hash-ext/mrblib/hash.rb
mrbgems/mruby-hash-ext/mrblib/hash.rb
@@ -62,8 +62,8 @@ class Hash
##
# call-seq:
- # hsh.merge!(other_hash) -> hsh
- # hsh.merge!(other_hash){|key, oldval, newval| block} -> hsh
+ # hsh.merge!(other_hash..) -> hsh
+ # hsh.merge!(other_hash..){|key, oldval, newval| block} -> hsh
#
# Adds the contents of _other_hash_ to _hsh_. If no block is specified,
# entries with duplicate keys are overwritten with the values from
@@ -81,7 +81,11 @@ class Hash
# #=> {"a"=>100, "b"=>200, "c"=>300}
#
- def merge!(other, &block)
+ def merge!(*others, &block)
+ i = 0; len=others.size
+ while i<len
+ other = others[i]
+ i += 1
raise TypeError, "Hash required (#{other.class} given)" unless Hash === other
if block
other.each_key{|k|
@@ -90,6 +94,7 @@ class Hash
else
other.each_key{|k| self[k] = other[k]}
end
+ end
self
end

MODIFY
mrbgems/mruby-hash-ext/test/hash.rb
mrbgems/mruby-hash-ext/test/hash.rb
@@ -64,6 +64,9 @@ assert('Hash#merge!') do
assert_raise(TypeError) do
{ 'abc_key' => 'abc_value' }.merge! "a"
end
+
+ # multiple arguments
+ assert_equal({a:1,b:2,c:3}, {a:1}.merge!({b:2},{c:3}))
end
assert('Hash#values_at') do

mruby-hash-ext/hash.rb (merge!): takes multiple arguments.