hash.rb (merge): now takes multiple arguments.
@@ -158,9 +158,13 @@ class Hash
# will be the final value of this element.
#
# ISO 15.2.13.4.22
- def merge(other, &block)
- raise TypeError, "Hash required (#{other.class} given)" unless Hash === other
+ def merge(*others, &block)
+ i=0; len=others.size
h = self.dup
+ while i<len
+ other = others[i]
+ i += 1
+ raise TypeError, "Hash required (#{other.class} given)" unless Hash === other
if block
other.each_key{|k|
h[k] = (self.has_key?(k))? block.call(k, self[k], other[k]): other[k]
@@ -168,6 +172,7 @@ class Hash
else
other.each_key{|k| h[k] = other[k]}
end
+ end
h
end
