From: angus Date: 2005-12-23T11:31:03+09:00 Subject: Re: oddity with block argument passing [Gustav Munkby , 2005-12-20 21.40 CET] [...] > Constructs = [ > lambda {|x, *y| [x, y]}, > proc {|x, *y| [x, y]}, > Proc.new {|x, *y| [x, y]} > ] > > puts "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]" > Constructs.each{ |x| puts x[[]].inspect } > > Below is the output of this script from the two versions of ruby where > I've tried it. > > $ ruby proc_test.rb > ruby 1.8.3 (2005-09-21) [i686-linux] > [[], []] > [[], []] > [nil, []] > > $ ruby-cvs proc_test.rb > ruby 1.9.0 (2005-12-20) [i686-linux] > [[], []] > [nil, []] > [nil, []] Compare: def a x, *y [x, y] end a [] # => [[], []] x, *y = [] [x, y] # => [nil, []] In one case, values are assigned as in normal assignment; in others, as in method parameter assignment. The "normal variable assignment" is to be expected in normal blocks; the ones created with lambda use parameter-like assignment. > Is this to be expected? Many people expect different things here, and you can find a lot of discussions about this topic in the list archives. HTH.