From: joshua.goodall@... Date: 2019-07-17T02:54:09+00:00 Subject: [ruby-core:93819] [Ruby master Feature#15975] Add Array#pluck Issue #15975 has been updated by inopinatus (Joshua GOODALL). You must've been very quick! - yes, there was a cut-and-paste error on show for a few minutes. It's now the code I intended to paste. ---------------------------------------- Feature #15975: Add Array#pluck https://bugs.ruby-lang.org/issues/15975#change-79686 * Author: lewispb (Lewis Buckley) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Inspired by https://github.com/rails/rails/issues/20339 While developing web applications I've often wanted to quickly extract an array of values from an array of hashes. With an array of objects, this is possible: ```rb irb(main):001:0> require 'ostruct' => true irb(main):002:0> [OpenStruct.new(name: "Lewis")].map(&:name) => ["Lewis"] ``` This PR adds Array#pluck allowing this: ```rb irb(main):001:0> [ {name: "Lewis"} ].pluck(:name) => ["Lewis"] ``` without this PR: ```rb irb(main):001:0> [ {name: "Lewis"} ].map { |item| item[:name] } => ["Lewis"] ``` Implemented here: https://github.com/ruby/ruby/pull/2263 -- https://bugs.ruby-lang.org/ Unsubscribe: