Why only inject() accepts :symbols as if it's a Proc in Enumerable?

e$B:XF#$H?=$7$^$9!#;38}$5$s$N%a!<%k$G;W$$=P$7$^$7$?!#e(B

e$B0JA0$?$7$+e(BMatze$BF|[email protected]$C$?$H;W$&$N$G$9$,!"e(B

e$B!Ve(B1.9e$B$G$O!Xe(B(1…10).inject(:+)e$B!Y$Ge(B1e$B!Ae(B10e$B$^$G$NOB$,7W;;$G$-$k$h!We(B

e$B$H$$$&$N$r8+$^$7$?!#3N$+$K>e5-$G!"8=>u$Ne(Btrunke$B$G$be(B55e$B$,=PNO$5$l$^$9!#e(B

$ ruby-trunk -ve ‘p (1…10).inject(:+)’
ruby 1.9.0 (2007-12-24 revision 0) [i686-linux]
-e:1: warning: (…) interpreted as grouped expression
55

e$B$=$NN`?d$Ge(B
(1…10).map(:to_s)
e$B$H$d$C$?$N$G$9$,!"8+;v$Ke(B

in to_s': wrong number of arguments(1 for 0) (ArgumentError) from -e:1:in

e$B$H%(%i!<$K$J$j$^$7$?!#e(B

e$B$=$N8e%=!<%9$r<P$aFI$$7$?$N$G$9$,!"$I$&$be(BEnumerablee$B$NCf$G$Oe(B
inject(reduce)e$B$N$
$,e(B

e$B!V%V%m%C%/$,M?$($i$l$:!"$+$D0z?t$Ke(BSymbole$B$r;XDj$7$?>l9g!“e(B
Symbole$B$re(BProce$B$H$7$F8+$ke(B(e$B$H$$$&$+!”$=$N$^$^e(Bfuncall()e$B$9$ke(B)e$B!We(B

e$B$H$$$&;EMM$G$"$k$h$&$G$9!#e(B

1.8e$B$G$OEvA3L58z$G$"$k$N$O3NG’$7$?$N$G$9$,!">e5-$O0U?^E*$J$b$N$G$7$g$&e(B
e$B$+!#$^$?$I$N$h$&[email protected]_7W>e$NM}M3$,$"$k$N$G$7$g$&$+!#e(B

e$BBP>[email protected]$K$O$=$3$^[email protected]$o$C$F$b$$$$$3$H$P$+$j$G$O$J$$!"$H$$$&$N$OF10U$7$^e(B
e$B$9$,!“FCJL$JM}M3$,L5$$8B$j$O$H$j$”$($:B7$($F$*$$$?J}$,!"$D$^$j$Oe(B

(1…10).inject(&:+)

[email protected]<(E*$Ke(B&e$B$Ge(BSymbol#to_proce$B$r8F$S=P$9$h$&%f!<%6$KMW5a$7$?J}$,NI$$$H;W$&e(B
e$B$N$G$9$,!"$I$&$G$7$g$&$+!#e(B

e$B$G$J$$$H!“6KC<$JNc$G$9$,!Ve(Binitiale$B$,e(BSymbole$B$G$”$ke(Binjecte$B$Ne(B

Enumeratore$B!W$r:n$l$J$$!"$H$$$&Nc30$,$G$-$k5$$,$7$^$9e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:32691] Why only inject() accepts :symbols as
if it’s a Proc in Enumerable?”
on Mon, 24 Dec 2007 02:53:00 +0900, Tadashi S.
[email protected] writes:

|e$B$=$N8e%=!<%9$r<P$aFI$$7$?$N$G$9$,!"$I$&$be(BEnumerablee$B$NCf$G$Oe(B
|inject(reduce)e$B$N$
$,e(B
|
|e$B!V%V%m%C%/$,M?$($i$l$:!"$+$D0z?t$Ke(BSymbole$B$r;XDj$7$?>l9g!“e(B
| Symbole$B$re(BProce$B$H$7$F8+$ke(B(e$B$H$$$&$+!”$=$N$^$^e(Bfuncall()e$B$9$ke(B)e$B!We(B
|
|e$B$H$$$&;EMM$G$"$k$h$&$G$9!#e(B
|
|1.8e$B$G$OEvA3L58z$G$"$k$N$O3NG’$7$?$N$G$9$,!">e5-$O0U?^E*$J$b$N$G$7$g$&e(B
|e$B$+!#$^$?$I$N$h$&[email protected]_7W>e$NM}M3$,$"$k$N$G$7$g$&$+!#e(B

e$B0U?^E*$J$b$N$G$9!#e(Binjecte$B$N0U?^!VMWAG$N4V$K1i;;e(B(e$B;Re(B)e$B$r:9$79~$`!We(B
e$B$r$h$jD>@\E*$KI=8=$7$h$&$H$$$&$b$N$G$9!#e(B

|e$BBP>[email protected]$K$O$=$3$^[email protected]$o$C$F$b$$$$$3$H$P$+$j$G$O$J$$!"$H$$$&$N$OF10U$7$^e(B
|e$B$9$,!“FCJL$JM}M3$,L5$$8B$j$O$H$j$”$($:B7$($F$$$$?J}$,!"$D$^$j$Oe(B
|
| (1…10).inject(&:+)
|
|[email protected]<(E
$Ke(B&e$B$Ge(BSymbol#to_proce$B$r8F$S=P$9$h$&%f!<%6$KMW5a$7$?J}$,NI$$$H;W$&e(B
|e$B$N$G$9$,!"$I$&$G$7$g$&$+!#e(B

mape$B$K0z?t$H$7$F%7%s%%k$rM?$($F$b!"e(Binjecte$B$[$I!V0U?^DL$j!W$He(B
e$B$$$&0u>]$rM?$($J$$$N$GJ]N1$7$F$$$^$9!#>-Mh$=$&$$$&H=CG$r$7$Je(B
e$B$$J]>Z$O$J$$$G$9$,!#e(B

|# e$B$G$J$$$H!“6KC<$JNc$G$9$,!Ve(Binitiale$B$,e(BSymbole$B$G$”$ke(Binjecte$B$Ne(B
|# Enumeratore$B!W$r:n$l$J$$!"$H$$$&Nc30$,$G$-$k5$$,$7$^$9e(B

e$B$=$l$O3N$+$G$9$,!"eLdBj$J$$$N$GJ|CV$7$F$b$+$^$o$J$$$H;We(B
e$B$$$^$9!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

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