Method: Weak::Map#default

Defined in:
lib/weak/map.rb

#default(key = UNDEFINED) ⇒ Object

Returns the default value for the given key. The returned value will be determined either by the default proc or by the default value. With no argument, returns the current default value (initially nil). If key is given, returns the default value for key, regardless of whether that key exists.

Parameters:

  • key (Object) (defaults to: UNDEFINED)

    if given, we return the default value for this key

Returns:

  • (Object)

    the default value for key if given, or weak map's default value



375
376
377
378
379
380
381
# File 'lib/weak/map.rb', line 375

def default(key = UNDEFINED)
  if UNDEFINED.equal? key
    @default_value
  else
    _default(key)
  end
end