method

pick

Importance_1
v7.0.0 - Show latest stable - 0 notes - Class: Enumerable
pick(*keys) public

Extract the given key from the first element in the enumerable.

[{ name: "David" }, { name: "Rafael" }, { name: "Aaron" }].pick(:name)
# => "David"

[{ id: 1, name: "David" }, { id: 2, name: "Rafael" }].pick(:id, :name)
# => [1, "David"]
Show source
Register or log in to add new notes.