Method: Weak::Map#values_at

Defined in:
lib/weak/map.rb

#values_at(*keys) ⇒ Array

Returns a new Array containing values for the given keys:

map = Weak::Map[foo: 0, bar: 1, baz: 2]
map.values_at(:baz, :foo)
# => [2, 0]

The default values are returned for any keys that are not found:

map.values_at(:hello, :foo)
# => [nil, 0]

Parameters:

  • keys (Array<Object>)

    a list of keys

Returns:

  • (Array)

    an Array containing the values for the given keys if present or the default value if not. The order of the given keys is preserved.



810
811
812
# File 'lib/weak/map.rb', line 810

def values_at(*keys)
  keys.map { |key| self[key] }
end