method

pluck

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

Extract the given key from each element in the enumerable.

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

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