# Block parameter complete?

e\$B!!\$5\$5\$@\$G\$9!#e(B

e\$B!!%V%m%C%/%Q%i%a!<%?\$K\$D\$\$\$F!"<+J,\$,GD0.\$7\$F\$\$\$kJ,\$K\$D\$\$\$F\$O<Be(B
e\$BAu\$7\$^\$7\$?!#\$J\$s\$+H4\$1\$,\$"\$C\$?\$i65\$(\$F\$/\$@\$5\$\$!#e(B

e\$B!!e(B1.8 e\$B\$H\$NAj0cE@\$O!"\$?\$V\$s\$3\$s\$J\$H\$3\$m\$G\$9!'e(B

e\$B!&J#?t0z?t\$G\$Ne(B yield e\$B\$r!"e(B1
e\$B0z?t\$N>l9gG[Ns\$H\$7\$F\$&\$1\$J\$\$e(B

## – ruby -ve “Proc.new{|a| p a}.call(1, 2)” ruby 1.8.5 (2006-08-25) [i486-linux] -e:1: warning: multiple values for a block parameter (2 for 1) from -e:1 [1, 2]

./miniruby -ve “Proc.new{|a| p a}.call(1, 2)”
ruby 1.9.0 (2007-06-25 patchlevel 0) [i686-linux]
1

e\$B!&e(Bpost arg e\$B\$NBP1~e(B

e\$B!!\$3\$l!“0lE@Fq\$7\$\$%]%\$%s%H\$,\$”\$C\$F!“e(B|a, b, *r, p1, p2|
e\$B\$N\$H\$-e(B
e\$B\$K!”!Ve(B3e\$B0z?t!WEO\$5\$l\$?\$H\$-!“e(Bp1 e\$B\$b\$7\$/\$Oe(B
p2e\$B!”\$I\$A\$i\$KF~\$l\$k\$Y\$-e(B
e\$B\$G\$7\$g\$&\$+!#\$H\$j\$"\$(\$:!":G8e\$Ke(B nil e\$B\$r\$D\$a\$?\$H2r<a\$7!"e(Bp1
e\$B\$XBeF~e(B
e\$B\$9\$k\$h\$&\$K<BAu\$7\$^\$7\$?!#e(B

e\$B!&%*%W%7%g%J%k0z?t\$NBP1~!Je(Blambdae\$B!Ke(B

e\$B!&%V%m%C%/0z?t\$NBP1~e(B

e\$B!&<B9TNc!'e(B

p :lambda
f = -> (m1, m2, o1=:o1, o2=:o2, *r, p1, p2) {[m1, m2, o1, o2,
r, p1, p2]}
(4…10).each{|e|
p ary = (0…e).to_a
p f.call(*ary)
puts
}

p :Proc
pr = Proc.new{|m1, m2, m3, *r, p1, p2, p3| [m1, m2, m3, r, p1,
p2, p3]}
(0…10).each{|e|
p ary = (0…e).to_a
p ary = pr.call(*ary)
puts
}

#=>
:lambda
[0, 1, 2, 3]
[0, 1, :o1, :o2, [], 2, 3]

[0, 1, 2, 3, 4]
[0, 1, 2, :o2, [], 3, 4]

[0, 1, 2, 3, 4, 5]
[0, 1, 2, 3, [], 4, 5]

[0, 1, 2, 3, 4, 5, 6]
[0, 1, 2, 3, [4], 5, 6]

[0, 1, 2, 3, 4, 5, 6, 7]
[0, 1, 2, 3, [4, 5], 6, 7]

[0, 1, 2, 3, 4, 5, 6, 7, 8]
[0, 1, 2, 3, [4, 5, 6], 7, 8]

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, [4, 5, 6, 7], 8, 9]

:Proc
[]
[nil, nil, nil, [], nil, nil, nil]

[0]
[0, nil, nil, [], nil, nil, nil]

[0, 1]
[0, 1, nil, [], nil, nil, nil]

[0, 1, 2]
[0, 1, 2, [], nil, nil, nil]

[0, 1, 2, 3]
[0, 1, 2, [], 3, nil, nil]

[0, 1, 2, 3, 4]
[0, 1, 2, [], 3, 4, nil]

[0, 1, 2, 3, 4, 5]
[0, 1, 2, [], 3, 4, 5]

[0, 1, 2, 3, 4, 5, 6]
[0, 1, 2, [3], 4, 5, 6]

[0, 1, 2, 3, 4, 5, 6, 7]
[0, 1, 2, [3, 4], 5, 6, 7]

[0, 1, 2, 3, 4, 5, 6, 7, 8]
[0, 1, 2, [3, 4, 5], 6, 7, 8]

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, [3, 4, 5, 6], 7, 8, 9]

e\$B!!\$5\$5\$@\$G\$9!#e(B

Tanaka A. wrote:

``````    from -e:2:in `m'
from -e:3:in `<main>'
``````

e\$B\$H\$\$\$&\$3\$H\$,\$*\$3\$k\$h\$&\$G\$9!#e(B

e\$B!!:#2s\$Ne(B postarg
e\$B\$NBP1~!"\$H\$\$\$C\$?\$N\$O%V%m%C%/%Q%i%a!<%?\$K\$D\$\$e(B
e\$B\$F\$G\$"\$C\$F!“8F\$S=P\$7;~\$NBP1~\$G\$O\$J\$+\$C\$?\$s\$G\$9\$,!”\$=\$l\$O\$=\$l\$He(B
e\$B\$7\$F!“0JA0\$+\$i\$”\$C\$?%P%0\$@\$C\$?\$h\$&\$J\$N\$G!"=\$@5\$7\$^\$7\$?!#e(B

e\$B!!e(Bm(*ary, …)
e\$B\$H\$\$\$&7A\$N8F\$S=P\$7\$KBP1~\$G\$-\$F\$\$\$J\$+\$C\$?\$h\$&\$G\$9!#e(B

In article [email protected],

e\$B!&e(Bpost arg e\$B\$NBP1~e(B

e\$B\$H\$j\$"\$(\$:!"e(B

% ./ruby -ve ’
def m(&b) p b; b.yield(*[:hahaha], 0) end
m {|*x| p x }’
ruby 1.9.0 (2007-06-26 patchlevel 0) [i686-linux]
#Proc:0xb7cc42d4@-e:3
-e:2:in `method_missing': undefined method `yield’ for [:hahaha]:Array
(NoMethodError)
from -e:2:in `m' from -e:3:in `

e\$B\$H\$\$\$&\$3\$H\$,\$*\$3\$k\$h\$&\$G\$9!#e(B

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

In message “Re: [ruby-dev:31047] block parameter complete?”
on Tue, 26 Jun 2007 00:57:16 +0900, SASADA Koichi [email protected]
writes:

|e\$B!&e(Bpost arg e\$B\$NBP1~e(B
|
|e\$B!!\$3\$l!“0lE@Fq\$7\$\$%]%\$%s%H\$,\$”\$C\$F!“e(B|a, b, *r, p1, p2| e\$B\$N\$H\$-e(B
|e\$B\$K!”!Ve(B3e\$B0z?t!WEO\$5\$l\$?\$H\$-!“e(Bp1 e\$B\$b\$7\$/\$Oe(B p2e\$B!”\$I\$A\$i\$KF~\$l\$k\$Y\$-e(B
|e\$B\$G\$7\$g\$&\$+!#\$H\$j\$“\$(\$:!”:G8e\$Ke(B nil e\$B\$r\$D\$a\$?\$H2r<a\$7!"e(Bp1 e\$B\$XBeF~e(B
|e\$B\$9\$k\$h\$&\$K<BAu\$7\$^\$7\$?!#e(B

e\$B\$=\$&\$+!"e(BProce\$B%b!<%I\$G\$O%(%i!<\$K\$J\$i\$J\$\$\$+\$i\$G\$9\$M!#e(Bp1e\$B\$X\$NBeF~e(B
(p2e\$B\$Oe(Bnil)e\$B\$GNI\$\$\$H;W\$\$\$^\$9!#e(B