Enumerable can't take multiple parameters

eache$B$GJ#?t$N%Q%i%a!<%?$re(Byielde$B$7$?$H$-$K!"e(BEnumerable#colecte$B$G!"e(B
[email protected],$NCM$7$+<u$1<h$l$J$$$h$&$G$9!#e(B

% ruby-1.9 -v -e ’
~
class Foo
include Enumerable
def each
{1=>2, 3=>4}.each{|k, v|
yield(k, v)
}
end
end

foo=Foo.new
foo.each{|k, v| p [k, v] }
foo.collect{|k, v| p [k, v] }

ruby 1.9.0 (2007-12-24 revision 0) [x86_64-linux]
[1, 2]
[3, 4]
[1, nil]
[3, nil]

e$B$3$N1F6A$G!"e(BRSSe$B$N%F%9%H$,<:GT$7$F$$$^$9!#e(B
e$B$3$N%1!<%9$G$Oe(BREXML::Elemenet#eache$B$r0J2<$N$h$&[email protected]$9$l$P4ue(B
e$BK>$9$kF0:n$K$J$j$^$9$,!"e(BEnumerablee$B$NLdBj$J$N$+e(Beache$B$r<BAu$9$ke(B
e$BB&$NLdBj$J$N$+H=CG$G$-$^$;$s$G$7$?!#e(B

— lib/rexml/element.rb (revision 14606)
+++ lib/rexml/element.rb (working copy)
@@ -1013,7 +1013,7 @@
# doc.root.attributes.each {|name, value| p name+" => "+value }
def each
each_attribute do |attr|

  •    yield attr.expanded_name, attr.value
    
  •    yield [attr.expanded_name, attr.value]
     end
    
    end

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

In message “Re: [ruby-dev:32708] Enumerable can’t take multiple
parameters”
on Mon, 24 Dec 2007 22:25:54 +0900, GOTOU Yuuzou
[email protected] writes:

|eache$B$GJ#?t$N%Q%i%a!<%?$re(Byielde$B$7$?$H$-$K!"e(BEnumerable#colecte$B$G!"e(B
|[email protected],$NCM$7$+<u$1<h$l$J$$$h$&$G$9!#e(B

1.8e$B$H0c$C$FJ#?t$NCM$rEO$95sF0$,[email protected]$K$J$C$?I{:nMQ$G$7$g$&!#$?e(B
e$B$H$($Pe(BEnumerable#collecte$B$re(BRubye$B$GDj5A$9$k;~$K$I$N$h$&$K=q$/$+!"e(B
e$B$H$$$&LdBj$G$9!#8=:_$Oe(B

module Enumerable
def collect
result = []
self.each{|x| result.push(yield x)}
result
end
end

e$B$HEy2A$K$J$k$h$&$KDj5A$7$F$$$^$9!#$o$j$H<+A3$G$O$J$$$G$7$g$&e(B
e$B$+!#$3$l$rA4It$NCM$r<u$1<h$j!"e(Byielde$B$KEO$9$?$a$K$Oe(B

module Enumerable
def collect
result = []
self.each{|*x| result.push(yield *x)}
result
end
end

e$B$H$J$j$^$9!#$I$C$A$,$$$$$+!"$G$9$M!#e(B

|e$B$3$N1F6A$G!"e(BRSSe$B$N%F%9%H$,<:GT$7$F$$$^$9!#e(B
|e$B$3$N%1!<%9$G$Oe(BREXML::Elemenet#eache$B$r0J2<$N$h$&[email protected]$9$l$P4ue(B
|e$BK>$9$kF0:n$K$J$j$^$9$,!"e(BEnumerablee$B$NLdBj$J$N$+e(Beache$B$r<BAu$9$ke(B
|e$BB&$NLdBj$J$N$+H=CG$G$-$^$;$s$G$7$?!#e(B

e$B8D?ME*$K$Oe(Beache$B$OJ#?t$NCM$re(Byielde$B$9$Y$-$G$O$J$$$H9M$($F>e$N$he(B
e$B$&$JDj5A$K$7$F$$$^$9!#$,!“M}[email protected]=E;kGI$G$b0U8GCO$K$J$C$F$$$k$oe(B
e$B$1$G$b$J$$$N$G!”<BMQE*$J%a%j%C%H$,$"$k$N$G$"$l$Pe(B(e$B:#$J$i$P$^e(B
[email protected](B)e$BJQ99$9$k$3$H$K$d$V$5$+$G$O$"$j$^$;$s!#e(B

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

In article
[email protected],
GOTOU Yuuzou [email protected] writes:

e$B$H$$$&$N$O$J$s$H$J$/ITJX$J5$$,$9$k$N$G!"J#?t$N%Q%i%a!<%?$r<ue(B
e$B$1<h$k$N$,L5Fq$G$O$J$$$G$7$g$&$+!#e(B

e$BLdBj$O<u$1<h$C$?8e$K$I$&$9$k$+!"$G$O$J$$$G$7$g$&$+!#e(B

e$B$?$H$($P!“e(Benum.max {|a, b| … } e$B$r$I$&Dj5A$9$k$+!”$H$+!#e(B

collect e$B$G$"$l$Pe(B

In message “Re: [ruby-dev:32708] Enumerable can’t take multiple parameters”
on Mon, 24 Dec 2007 22:25:54 +0900, GOTOU Yuuzou [email protected] writes:

module Enumerable
def collect
result = []
self.each{|*x| result.push(yield *x)}
result
end
end

e$B$H!"$"$kDxEY$O<+A3$KDj5A$G$-$^$9$,!"e(Bmax e$B$rF1MM$KDj5A$9$k$N$Oe(B
e$BFq$7$$$h$&$K;W$$$^$9!#e(B

e$BJ#?t$NCM$H$$$&$N$,$U$?$D$"$C$F!"$=$l$r$R$H$D$NG[Ns$H$O6hJL$Ge(B
e$B$-$k7A$G%V%m%C%/$KEO$;$k$N$+$H$$$&$H!“4JC1$G$O$J$5$=$&$G$9!#e(B
e$B$^$?!“e(Bmax e$B$NJV$jCM$b8+$D$1$?$b$N$,J#?t$”$C$?$H$-$KG[Ns$H6hJLe(B
e$B$7$FJV$;$k$+$H$$$&$H!”$3$l$bFq$7$=$&$G$9!#e(B

e$B$^$!!“e(BEnumerable e$B$,J#?t$N%Q%i%a!<%?$r<u$1<h$C$?$iG[Ns$r<u$1e(B
e$B<h$C$?$b$N$H$9$k$H$$$&$N$O$”[email protected]$k$+$b$7$l$^$;$s!#e(B

In message [email protected],
`Yukihiro M. [email protected]’ wrote:

|e$B$3$N1F6A$G!"e(BRSSe$B$N%F%9%H$,<:GT$7$F$$$^$9!#e(B
|e$B$3$N%1!<%9$G$Oe(BREXML::Elemenet#eache$B$r0J2<$N$h$&[email protected]$9$l$P4ue(B
|e$BK>$9$kF0:n$K$J$j$^$9$,!"e(BEnumerablee$B$NLdBj$J$N$+e(Beache$B$r<BAu$9$ke(B
|e$BB&$NLdBj$J$N$+H=CG$G$-$^$;$s$G$7$?!#e(B

e$B8D?ME*$K$Oe(Beache$B$OJ#?t$NCM$re(Byielde$B$9$Y$-$G$O$J$$$H9M$($F>e$N$he(B
e$B$&$JDj5A$K$7$F$$$^$9!#$,!“M}[email protected]=E;kGI$G$b0U8GCO$K$J$C$F$$$k$oe(B
e$B$1$G$b$J$$$N$G!”<BMQE*$J%a%j%C%H$,$"$k$N$G$"$l$Pe(B(e$B:#$J$i$P$^e(B
[email protected](B)e$BJQ99$9$k$3$H$K$d$V$5$+$G$O$"$j$^$;$s!#e(B

e$B8=:_$NF0:n$O!"e(BEnumerablee$B$N;EMM$H$7$FG<[email protected]$G$-$k$N$G$9$,!“e(B
REXML::Attributese$B$NNc$N$h$&$Ke(BHashe$B$r%i%C%W$9$k%/%i%9$r:n$k;~e(B
e$B$O!”$D$$!"e(B

def each
@hash.each do |k, v|
yield(k, v)
end
end

e$B$3$N$h$&$K=q$$$F$7$^$$$=$&$J5$$,$7$^$9!#$3$N;~!"e(B

  • [email protected]$1$O0U?^$7$?DL$j$KF0$$$F$7$^$&e(B
  • Enumerablee$B$N%a%=%C%I$r8F$S=P$7$F$bCM$,[email protected]$1$Ge(B
    e$B$H$j$"$($:F0$$$F$7$^$&e(B
  • e$B0[>o$K5$$E$$$F$b2?$i$+$N<(:6$,$J$$$H860xe(B(yeilde$B$N8F$S=P$7e(B
    e$BJ}e(B)e$B$^$G$?$I$jCe$/$N$K6lO+$7$=$&e(B

e$B$H$$$&$N$O$J$s$H$J$/ITJX$J5$$,$9$k$N$G!"J#?t$N%Q%i%a!<%?$r<ue(B
e$B$1<h$k$N$,L5Fq$G$O$J$$$G$7$g$&$+!#e(B

In message [email protected],
`Tanaka A. [email protected]’ wrote:

In article [email protected],
GOTOU Yuuzou [email protected] writes:

e$B$H$$$&$N$O$J$s$H$J$/ITJX$J5$$,$9$k$N$G!"J#?t$N%Q%i%a!<%?$r<ue(B
e$B$1<h$k$N$,L5Fq$G$O$J$$$G$7$g$&$+!#e(B

e$BLdBj$O<u$1<h$C$?8e$K$I$&$9$k$+!"$G$O$J$$$G$7$g$&$+!#e(B

e$B$?$H$($P!“e(Benum.max {|a, b| … } e$B$r$I$&Dj5A$9$k$+!”$H$+!#e(B
(snip)
e$BJ#?t$NCM$H$$$&$N$,$U$?$D$"$C$F!"$=$l$r$R$H$D$NG[Ns$H$O6hJL$Ge(B
e$B$-$k7A$G%V%m%C%/$KEO$;$k$N$+$H$$$&$H!“4JC1$G$O$J$5$=$&$G$9!#e(B
e$B$^$?!“e(Bmax e$B$NJV$jCM$b8+$D$1$?$b$N$,J#?t$”$C$?$H$-$KG[Ns$H6hJLe(B
e$B$7$FJV$;$k$+$H$$$&$H!”$3$l$bFq$7$=$&$G$9!#e(B

e$B$O$$!#$=$l$OF10U$7$^$9!#e(B

e$B$7$+$7!"<gD%$7$?$$$N$Oe(Byielde$B$KEO$7$?CM$N0lIt$,<N$F$i$l$k$H$$e(B
e$B$&F0:n$,$7$C$/$j$3$J$$$H$3$m$G$9$+$M!#e(B

Enumerable::Enumeratore$B$b8+$F$$$?$N$G$9$,!"e(Byield(a, b)e$B$H$$$&e(B
e$B7A<0$G8F$s$G$$$k%a%=%C%I$r%i%C%W$7$?>l9g!“e(BEnumerablee$B$N%a%=%Ce(B
e$B%I$+$ie(Bbe$B$K%”%/%;%9$G$-$J$/$J$k$N$OITJX$8$c$J$$$G$7$g$&$+!)e(B

e$B$^$!!“e(BEnumerable e$B$,J#?t$N%Q%i%a!<%?$r<u$1<h$C$?$iG[Ns$r<u$1e(B
e$B<h$C$?$b$N$H$9$k$H$$$&$N$O$”[email protected]$k$+$b$7$l$^$;$s!#e(B

e$BJ#?t$NCM$,$"$k>l9g$OG[Ns$K5M$a$FEO$9$h$&[email protected]$m$&$H$$e(B
e$B$&M=A[$+$i!"E,Ev$JF0:[email protected]$H;W$$$^$9!#e(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