summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-hash-ext/mrblib/hash.rb
blob: 3e1bac0a20aee09fad8b068b55b566ceac770e01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
class Hash
  def merge!(other, &block)
    if block
      other.each_key{|k|
        self[k] = (self.has_key?(k))? block.call(k, self[k], other[k]): other[k]
      }
    else
      other.each_key{|k| self[k] = other[k]}
    end
    self
  end
end