Module: Corefines::Hash::OpAdd

Defined in:
lib/corefines/hash.rb

Instance Method Summary collapse

Instance Method Details

#+(other_hash) ⇒ Hash

Alias for #merge.

Examples:

{a: 1, b: 2} + {b: 3, c: 4}
 => {a: 1, b: 3, c: 4}

Parameters:

Returns:

  • (Hash)

    a new hash containing the contents of other_hash and this hash. The value for entries with duplicate keys will be that of other_hash.


164
165
166
167
168
169
170
# File 'lib/corefines/hash.rb', line 164

module OpAdd
  refine ::Hash do
    def +(other_hash)
      merge other_hash
    end
  end
end