Method: FunRuby::Hash#values_at

Defined in:
lib/fun_ruby/hash.rb

#values_at(keys = F._, hash = F._) ⇒ ::Array[Object]

Returns an array of values stored by given keys If a key is missed the default value is returned

Examples:

Base

hash = { name: "John", age: 20, country: "USA" }

F::Hash.values_at([:name, :age, :country], hash) # => ["John", 20, "USA"]
F::Hash.values_at([:address, :email, :country, :age], hash) # => [nil, nil, "USA", 20]

Parameters:

  • keys (::Array of (#hash, #eql?)) (defaults to: F._)
  • hash (#to_h) (defaults to: F._)

Returns:

  • (::Array[Object])

Since:

  • 0.1.0



284
285
286
# File 'lib/fun_ruby/hash.rb', line 284

def values_at(keys = F._, hash = F._)
  curry_implementation(:values_at, keys, hash)
end