Method: Weak::Map#delete

Defined in:
lib/weak/map.rb

#delete(key = UNDEFINED) {|key| ... } ⇒ Object?

Note:

Weak::Map does not test member equality with ‘==` or `eql?`. Instead, it always checks strict object equality, so that, e.g., different String keys are not considered equal, even if they may contain the same content.

Deletes the key-value pair and returns the value from ‘self` whose key is equal to `key`. If the key is not found, it returns `nil`. If the optional block is given and the key is not found, pass in the key and return the result of the block.

Parameters:

  • key (Object) (defaults to: UNDEFINED)

    the key to delete

Yields:

  • (key)

Yield Parameters:

  • key (Object)

    the given ‘key` if it was not part of the map

Returns:

  • (Object, nil)

    the value associated with the given ‘key`, or the result of the optional block if given the key was not found, or `nil` if the key was not found and no block was given.

[View source]

# File 'lib/weak/map.rb', line 236