From: ben@... Date: 2015-02-04T22:59:05+00:00 Subject: [ruby-core:68013] [CommonRuby - Feature #10829] [Open] Add to_proc method to the Array class Issue #10829 has been reported by Ben Morgan. ---------------------------------------- Feature #10829: Add to_proc method to the Array class https://bugs.ruby-lang.org/issues/10829 * Author: Ben Morgan * Status: Open * Priority: Normal * Assignee: ---------------------------------------- In ruby, we've all seen this shortcut: ```ruby user.posts.map(&:title) ``` The expanded version is: ```ruby user.posts.map { |post| post.title } ``` Sometimes, however, that method might take arguments. This feature proposal is to allow the `to_proc` shortcut to be able to respond to the `Array` class. This would allow developers to be able to use the shortcut to be able to pass in arguments. This can currently be done by reopening the `Array` class and supplying it with a `to_proc` method: ```ruby class Array def to_proc proc { |receiver| receiver.send *self } end end ``` This would allow this code to be able to run: ```ruby [1, 2, 3, 4, 5].map([:+, 3]) # => [4, 5, 6, 7, 8] ``` -- https://bugs.ruby-lang.org/