Project

General

Profile

Actions

Feature #2691

closed

RCR: allow {select, collect, map} to accept symbol argument

Added by yugui (Yuki Sonoda) about 14 years ago. Updated almost 13 years ago.

Status:
Rejected
Target version:
-
[ruby-core:27967]

Description

=begin
This reply registers the suggestion by Roger to the redmine.

and -1 because a method name is not a method itself.
Symbol#to_proc is the limit I can accept.

On Sat, Jan 30, 2010 at 10:14 AM, Roger Pack wrote:

Background.

Currently in order to avoid using braces and to use select/map et al,
one must do

collection.map &:symbol

This is quite explicit, which is good, however the syntax is somewhat
ugly, which is surprising (mostly because the punctuation is
somewhat...hard to read, at least for this Ruby reader).

Suggestion:

Allow map/etc al to accept a single argument, and convert it implicitly to proc.

collection.map(:symbol)

This reads more easily.

Another option would be to add map_by(arg) and collect_by(arg)

which would actually be more preferable, as least for me.

Thoughts?
Thanks.
-r

-- Yuki Sonoda (Yugui)
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0