Method: Weak::Map#replace

Defined in:
lib/weak/map.rb

#replace(map) ⇒ self

Replaces the contents of self with the contents of the given Hash-like object and returns self.

If the given map defines a #default value or #default_proc, this will also replace the respective seting in self.

Examples:

map = Weak::Map[a: 1, b: 3, c: 1] #=> #<Weak::Map {a: 1, b: 3, c: 1}>
map.replace({x: :y})              #=> #<Weak::Map {x: :y}>
map                               #=> #<Weak::Map {x: :y}>

Parameters:

  • map (Weak::Map, Hash, #to_hash)

    a Weak::Map or a Hash object or an object which can be converted to a Hash by calling to_hash on it

Returns:

  • (self)


638
639
640
# File 'lib/weak/map.rb', line 638

def replace(map)
  initialize_copy(_implicit(map))
end