Def m(a=nil, b)

e$B$U$H!“e(B1.9 e$B$J$ie(B (TCPServer#initialize e$B$N$h$&$Ke(B)
e$BBh0l0z?t$r>Je(B
e$BN,2DG=$J%a%=%C%I$re(B def m(a=nil, b) e$B$HDj5A$G$-$k$N$G$O$J$+$me(B
e$B$&$+!”$HA[A|$7!";n$7$F$_$?$N$G$9$,!"$G$-$J$$$h$&$G$9!#e(B

% ./ruby -ve ‘def m(a=nil, b) end’
ruby 1.9.0 (2006-07-10) [i686-linux]
-e:1: syntax error, unexpected ‘)’, expecting ‘=’
def m(a=nil, b) end
^

def m(a=nil, *x, b) end e$B$J$iDL$k$o$1$G$9$,!"$I$&$b;d$O$3$N5!e(B
e$BG=$r!VI,?\0z?t$r:G8e$K$D$1$i$l$k!W$HM}2r$7$F$$$?$h$&$G$9!#e(B

e$B<B:]$K$O$=$&<BAu$5$l$F$O$$$J$+$C$?$o$1$G$9$,!"$9$3$79M$($F$_e(B
e$B$?$H$3$m!"$=$&$G$"$C$F$O$$$1$J$$M}M3$b;W$$IU$+$:!"$^$?!“e(B
TCPServer#initialize e$B$N$h$&$K$=$&9M$($?$[$&$,JXMx$JNc$b$”$je(B
e$B$^$9!#e(B

e$B$"$H!“e(B[ruby-dev:28715] e$B$N:G=i$NLdBj$O!”$3$N5!G=$N$H$i$($+$?e(B
e$B$N0c$$$+$iH/@[email protected]$m$&$+$J$I$H$b46$8$^$9!#e(B

e$B$J$N$G!"$G$-$?$i$$$$$s$G$O$J$+$m$&$+$H;W$C$?$N$G$9$,!"$I$&$Ge(B
e$B$7$g$&e(B?

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

In message “Re: [ruby-dev:29014] def m(a=nil, b)”
on Tue, 11 Jul 2006 12:51:33 +0900, Tanaka A. [email protected]
writes:

|e$B$U$H!“e(B1.9 e$B$J$ie(B (TCPServer#initialize e$B$N$h$&$Ke(B) e$BBh0l0z?t$r>Je(B
|e$BN,2DG=$J%a%=%C%I$re(B def m(a=nil, b) e$B$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:!"$=$l$r;Y1g$9$k5!G=$r$D$1$k$3$H$K$b>C6KE
$G$9!#$d$j$?$1$le(B
e$B$P<+J,$G$d$C$F$M!"$H!#e(B

e$B<BAu$,:#$h$j$bBgJQ$H$$$&$N$b$"$k$N$G$9$,!"$=$l$OLLE][email protected]$1$Ge(B
e$BIT2DG=$G$b:$Fq$G$b$J$$$N$G$9$,!"[email protected]$1$NF05!$E$1$O$J$$$J!"e(B
e$B$H!#e(B

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

In article [email protected],
Yukihiro M. [email protected] writes:

e$B$G$9$M!#e(B
e$B0z$-Gm$,$9!"$H$$$&I=8=$r;H$&$J$i!"0J2<$NF0:n$r8+$k8B$j!"e(Brest
[email protected]$1$G$J$/e(B optionale$B0z?t$+$i$b0z$-Gm$,$7$^$9!#e(B

% ./ruby -e ’
def m(a, b=nil, *c, d)
p [a,b,c,d]
end
m(1,2)’
[1, nil, [], 2]

% ./ruby -e ’
def m(a, b=nil, *c)
p [a,b,c]
end
m(1,2)’
[1, 2, []]

lm(a, b=nil, *c) e$B$Ge(B b e$B$KF~$C$F$$$?0z?t$,0z$-Gm$,$5$l$F!"e(B
m(a, b=nil, *c, d) e$B$G$Oe(B d e$B$KF~$C$F$$$^$9!#e(B

e$B=>$C$F!"!Ve(Breste$B0z?t$+$iI,?\0z?t$r0z$-Gm$,$9!W5!G=$H$$$&@bL@$Oe(B
e$B8=:_$N<BAu$K9g$C$F$$$J$$$h$&$K;W$$$^$9!#e(B

e$B;d$H$7$F$O!“E,@[email protected]@$O!VI,?\0z?t$r8e$m$K$b$D$1$i$l$k!W5!G=e(B
e$B$G$”$k$HM=A[$7$?$o$1$G$9$,!"$=$&$G$b$J$$$H$9$k$H!"$I$&@bL@$9e(B
e$B$k$N$G$7$g$&e(B?

def m(a=nil, b)

e$B$N>l9g!“e(Breste$B0z?t$,$”$j$^$;$se(B(e$B$+$i8=>u$O5v$5$l$J$$e(B)e$B!#$3$l$r5ve(B
e$B$7$?>l9g!“e(Bm(1)e$B$H$7$?>l9g!”=g=x$rM%@h$9$k$J$ie(B1e$B$Oe(Bae$B$KBeF~$5$l$ke(B
e$B$Y$-$G$O$J$$$+$H!#=g=x$rM%@h$7$J$$$J$i!"$`$7$m%-!<%o!<%I0z?te(B
(e$BL>A0IU$-0z?te(B)e$B$N$h$&$J$b$N$,K>$^$7$$$H;W$$$^$9!#e(B

e$B>e5-$N$h$&$K!"e(Boptional e$B0z?t$+$i$b0z$-Gm$,$9$N$G!"e(B1 e$B$Oe(B
b e$B$KBee(B
e$BF~$5$l$k$H;d$OM=A[$7$^$7$?!#e(B

e$B%-!<%o!<%I0z?t$,M_$7$$$H$$$&$N$O$=$l$O$=$l$G$"$j$^$9$,!"$3$Ne(B
e$B7o$K$D$$$F$O9M$($F$$$^$;$s$G$7$?!#e(B

e$B$P<+J,$G$d$C$F$M!"$H!#e(B

e$B<BAu$,:#$h$j$bBgJQ$H$$$&$N$b$"$k$N$G$9$,!"$=$l$OLLE][email protected]$1$Ge(B
e$BIT2DG=$G$b:$Fq$G$b$J$$$N$G$9$,!"[email protected]$1$NF05!$E$1$O$J$$$J!"e(B
e$B$H!#e(B

e$B$J$k$[$I!#$^$!!";Y1g$7$?$/$J$$$N$G$"$l$P<BAu$7$J$$$N$OM-$j$Ge(B
e$B$9$,!"@bL@$H<BAu$,9g$C$F$$$J$$$N$O$I$&$+$H;W$$$^$9!#e(B

e$B$b$A$m$s!"@bL@:$Fq$J5sF0$O$9$G$K$$$/$i$G$b$"$k$o$1$G$b$"$j$^e(B
e$B$9$,e(B…

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

In message “Re: [ruby-dev:29017] Re: def m(a=nil, b)”
on Tue, 11 Jul 2006 13:40:40 +0900, Tanaka A. [email protected]
writes:

|> e$B$(!<$H!“8=>u!”$3$l$O!Ve(Breste$B0z?t$+$iI,?\0z?t$r0z$-Gm$,$9!W5!G=e(B
|> e$B$G$9$M!#e(B
|
|e$B0z$-Gm$,$9!"$H$$$&I=8=$r;H$&$J$i!"0J2<$NF0:n$r8+$k8B$j!"e(Brest
|[email protected]$1$G$J$/e(B optionale$B0z?t$+$i$b0z$-Gm$,$7$^$9!#e(B

e$B$"$"!"$=$&$G$7$?!#e(B[ruby-dev:28715]e$B$r<u$1$F$=$N$h$&[email protected]$7$?e(B
e$B$N$G$7$?!#$H$J$k$H!"$I$&$7$?$b$N$+$J!#e(B

|e$B$J$k$[$I!#$^$!!";Y1g$7$?$/$J$$$N$G$"$l$P<BAu$7$J$$$N$OM-$j$Ge(B
|e$B$9$,!"@bL@$H<BAu$,9g$C$F$$$J$$$N$O$I$&$+$H;W$$$^$9!#e(B

e$B$=$&$G$9$M!#@bL@$H<BAu$O9g$o$;$?$[$&$,$h$$$H;W$$$^$9!#$G!"$Ie(B
e$B$&9g$o$;$k$+$G$9$M!#e(B

In article [email protected],
Yukihiro M. [email protected] writes:

e$B$&9g$o$;$k$+$G$9$M!#e(B
e$B0JA0e(B Matze$B$K$C$-$K5-=R$"$C$?$O$:[email protected]!"$H;W$C$FC5$7$F8+$^$7$?!#e(B

mandatory arguments after splat
http://www.rubyist.net/~matz/20060601.html#p03

RCR 315: allow required arguments after optional arguments
http://www.rcrchive.net/rcr/show/315

e$B>/$J$/$H$b!"e(BRCR 315 e$B$O!VI,?\0z?t$r8e$m$K$b$D$1$i$l$k!W5!G=$re(B
e$B0U?^$7$F$$$k$h$&$G$9!#8e$m$KIU$1$?I,?\0z?t$r<h$j=P$7$F$+$i!“e(B
optional, rest e$B$r=hM}$7$F$$$^$9!#$3$l$O;d$,A[Dj$7$?5!G=$=$Ne(B
e$B$b$N$G$”$j!"e(B[ruby-dev:29014]
e$B$N$h$&$J5!G=$bA[Dj$5$l$F$$$^$9!#e(B

Also consider the cases where the optional arguments (c,d)
or the splatted arg array (e) aren’t there.
e$B$H$$$&5-=R$b$"$j!“e(Brest [email protected]$1!”$H$$$&2r<a$O=PMh$^$;$s!#e(B

Matze$B$K$C$-$N5-=R$O$"$^$j$O$C$-$j$7$^$;$s$,!"e(Bafter splat e$B$H$$e(B
e$B$&%?%$%H%k$K$O!"e(Brest
e$B$+$i$H$$$&0U?^$J$$$7<BAu$,46$8$i$l$^$9!#e(B
e$B$,!"e(BRCR 315 e$B$+$i$=$&JQ2=$7$?M}M3$O5-:$5$l$F$$$^$;$s!#e(B

e$B$J$s$G!“e(BRCR 315 e$B$N$h$&$Je(B (e$B$”$k$$$O;d$,A[A|$7$?$h$&$Je(B)
e$B$b$N$+e(B
e$B$i!“e(Brest [email protected]$1!”$HJQ$($?$s$G$9$+e(B?

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

In message “Re: [ruby-dev:29020] Re: def m(a=nil, b)”
on Tue, 11 Jul 2006 15:55:58 +0900, Yukihiro M.
[email protected] writes:

|e$B$=$&$G$9$M!#@bL@$H<BAu$O9g$o$;$?$[$&$,$h$$$H;W$$$^$9!#$G!"$Ie(B
|e$B$&9g$o$;$k$+$G$9$M!#e(B

e$B$G!“9M$($?$N$G$9$,!”$d$O$je(Bsplate$B$N$J$$>l9g$G$b8e$m$NI,?\0z?te(B
e$B$O5v$9$3$H$K$7$^$7$?!#$5$-$[$I%3%_%C%H$7$^$7$?!#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