This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.
# Hash.merge! (from ruby core) --- merge!(*args) --- Merges each of `other_hashes` into `self`; returns `self`. Each argument in `other_hashes` must be a Hash. Method #update is an alias for #merge!. With arguments and no block: * Returns `self`, after the given hashes are merged into it. * The given hashes are merged left to right. * Each new entry is added at the end. * Each duplicate-key entry's value overwrites the previous value. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} With arguments and a block: * Returns `self`, after the given hashes are merged. * The given hashes are merged left to right. * Each new-key entry is added at the end. * For each duplicate key: * Calls the block with the key and the old and new values. * The block's return value becomes the new value for the entry. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h3 = h.merge!(h1, h2) { |key, old_value, new_value| old_value + new_value } h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} With no arguments: * Returns `self`, unmodified. * The block, if given, is ignored. Example: h = {foo: 0, bar: 1, baz: 2} h.merge # => {:foo=>0, :bar=>1, :baz=>2} h1 = h.merge! { |key, old_value, new_value| raise 'Cannot happen' } h1 # => {:foo=>0, :bar=>1, :baz=>2} (This method is an alias for Hash#update.) Merges each of `other_hashes` into `self`; returns `self`. Each argument in `other_hashes` must be a Hash. Method #update is an alias for #merge!. With arguments and no block: * Returns `self`, after the given hashes are merged into it. * The given hashes are merged left to right. * Each new entry is added at the end. * Each duplicate-key entry's value overwrites the previous value. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} With arguments and a block: * Returns `self`, after the given hashes are merged. * The given hashes are merged left to right. * Each new-key entry is added at the end. * For each duplicate key: * Calls the block with the key and the old and new values. * The block's return value becomes the new value for the entry. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h3 = h.merge!(h1, h2) { |key, old_value, new_value| old_value + new_value } h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} With no arguments: * Returns `self`, unmodified. * The block, if given, is ignored. Example: h = {foo: 0, bar: 1, baz: 2} h.merge # => {:foo=>0, :bar=>1, :baz=>2} h1 = h.merge! { |key, old_value, new_value| raise 'Cannot happen' } h1 # => {:foo=>0, :bar=>1, :baz=>2}
This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.