[Assigned] Improvement of Symbol and Proc

Issue #4146 has been updated by nahi.

Description updated
Status changed from Open to Assigned
Assignee set to ko1


Feature #4146: Improvement of Symbol and Proc
https://bugs.ruby-lang.org/issues/4146#change-24898

Author: nobu
Status: Assigned
Priority: Normal
Assignee: ko1
Category: core
Target version:

=begin
現在Symbol#to_procで %w[12 45 32].map(&:to_i) のようなことはできますが、
引数を付けてメソッドを呼ぶことはできません。Symbolリテラルに引数を付け
たらその引数と共にメソッドを呼ぶProcを作る構文というのはどうでしょうか。

%w[12 45 32].map(&:to_i(9)).map(&:*(2)) #=> [22, 82, 58]
%w[abc def ghi].map(&:[1]) #=> [“b”, “e”, “h”]
=end

Hi,

In message “Re: [ruby-dev:45394] [ruby-trunk - Feature #4146][Assigned]
Improvement of Symbol and Proc”
on Sun, 18 Mar 2012 18:47:11 +0900, nahi [email protected]
writes:

| $B8=:_(BSymbol#to_proc$B$G(B %w[12 45 32].map(&:to_i)
$B$N$h$&$J$3$H$O$G$-$^$9$,!"(B
| $B0z?t$rIU$1$F%a%=%C%I$r8F$V$3$H$O$G$-$^$;$s!#(BSymbol$B%j%F%i%k$K0z?t$rIU$1(B
| $B$?$i$=$N0z?t$H6&$K%a%=%C%I$r8F$V(BProc$B$r:n$k9=J8$H$$$&$N$O$I$&$G$7$g$&$+!#(B

Symbol$B$N9=J8$KFCJL$J3HD%$rF3F~$9$k$3$H$K$OH?BP$G$9!#$=$N$h$&(B
$B$J%*%V%8%’%/%H$r:n$k%/%i%9$K$OH?BP$7$^$;$s!#$I$&$;$J$i%7%s%(B
$B%k$+$iFHN)$7$?9=J8$rF3F~$9$l$P!"$H$b;W$$$^$9!#(B

$B$,!"9=J83HD%$K4JC1$K;[email protected]$7$?$j$O$7$^$;$s!#G0$N0Y!#(B

$B4d7n$H?=$7$^$9!#(B

Array#to_proc$B$r<BAu$9$k$H$$$&$N$O$$$+$,$G$7$g$&$+(B?
$B<BAuNc(B:
http://www.sanityinc.com/articles/adding-array-to-proc-to-ruby

%w[12 45 32].map(&[:to_i, 9]).map(&[:*, 2]) #=> [22, 82, 58]
%w[abc def ghi].map(&[:[], 1]) #=> [“b”, “e”, “h”]

Hiroyuki I. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs