class Concurrent::Map

def fetch(key, default_value = NULL)

Experimental RBS support (using type sampling data from the type_fusion project).

def fetch: ((String | Hash) key, ?Object default_value) -> (Array[String] | nil | ActionView::TemplateDetails::Requested)

This signature was generated using 3 samples from 1 application.

Other tags:
    Note: - The "fetch-then-act" methods of `Map` are not atomic. `Map` is intended

Raises:
  • (KeyError) - when key is missing and no default_value is provided

Returns:
  • (Object) - the value or default value

Other tags:
    Yieldreturn: - default value

Other tags:
    Yieldparam: key -

Other tags:
    Yield: - default value for a key

Parameters:
  • default_value (Object) --
  • key (Object) --
def fetch(key, default_value = NULL)
  if NULL != (value = get_or_default(key, NULL))
    value
  elsif block_given?
    yield key
  elsif NULL != default_value
    default_value
  else
    raise_fetch_no_key
  end
end