method

pluck

Importance_1
Ruby on Rails latest stable (v7.1.3.2) - 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.