Project

General

Profile

Feature #2691

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

Added by yugui (Yuki Sonoda) over 9 years ago. Updated over 8 years ago.

Status:
Rejected
Priority:
Normal
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 rogerdpack2@gmail.com 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

History

#1

Updated by mame (Yusuke Endoh) over 9 years ago

=begin
Hi,

2010/1/30 Yugui yugui@yugui.jp:

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.

While I agree with Yugui, Array#inject accepts a Symbol.
I dislike the behavior of inject.

--
Yusuke ENDOH mame@tsg.ne.jp

=end

#2

Updated by zenspider (Ryan Davis) over 9 years ago

=begin

On Jan 30, 2010, at 00:10 , Yugui wrote:

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.

I completely agree on this point. I want something explicit, not magic.

=end

#3

Updated by RickDeNatale (Rick DeNatale) over 9 years ago

=begin
On Sun, Jan 31, 2010 at 5:28 PM, Ryan Davis ryand-ruby@zenspider.com wrote:

On Jan 30, 2010, at 00:10 , Yugui wrote:

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.

I completely agree on this point. I want something explicit, not magic.

I agree as well. -1 on Roger's suggestion.

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

=end

#4

Updated by ujihisa (Tatsuhiro Ujihisa) over 9 years ago

  • Status changed from Open to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)

=begin

=end

#5

Updated by mame (Yusuke Endoh) over 9 years ago

  • Status changed from Assigned to Rejected

=begin
Hi,

This ticket got four -1s, and there is no rebuttal.
So I close this ticket.

FYI, matz stated the rationale (in Japanese). [ruby-dev:32692]
He thought that "inject with Symbol" directly expressed the
intention of Array#inject, and that "map with Symbol" did not.
But he also said he might change of heart in the future.
I advise you guys to lobby matz patiently :-)

--
Yusuke Endoh mame@tsg.ne.jp
=end

Also available in: Atom PDF