Skip to content
instance method

Hash#values_at

(*K arg0) -> ::Array[V?]
values_at(*keys) → new_array

Returns a new array containing values for the given keys:

Example
h = {foo: 0, bar: 1, baz: 2}
h.values_at(:baz, :foo) # => [2, 0]

The hash default is returned for each key that is not found:

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

Related: see Methods for Fetching.

See also #values #value? also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0