On 8/3/06, Tammo Freese <freese / acm.org> wrote:
>
> Robert Dober wrote:
> [...]
> > and it seems to make it into Ruby2 since June
> > http://pub.cozmixng.org/~the-rwiki/?
> > cmd=view;name=Ruby2.0BlockParameterAndMultipleValueAssignment
> > which I consider extremly good news :)
>
>
> I am suprised that the blocks will work in such a way.
> How do these play together with the new define_method ?
>
> Examples from
> http://pub.cozmixng.org/~the-rwiki/?
> cmd=view;name=Ruby2.0BlockParameterAndMultipleValueAssignment
> :
>
> - Proc.new{|x| x}.call(0,1) returns 0.
> - Proc.new{|x,y| [x,y]}.call(0) returns [0,nil].
>
> So missing arguments seem to be set to nil, and additional arguments
> seem to be ignored. What would happen for this code fragment:

That first example is a change from 1.8

Proc.new {|x| x}.call(0,1)
(irb):58: warning: multiple values for a block parameter (2 for 1)
        from (irb):58
=> [0, 1]

I'm not sure that I like this change.


-- 
Rick DeNatale

IPMS/USA Region 12 Coordinator
http://ipmsr12.denhaven2.com/

Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/