angus wrote: > [Gustav Munkby <grddev / gmx.net>, 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. > thanks for this explanation, now i really understand why there's a difference between the parameter-like assignment and normal variable assignment. they way you say it, it sounds as if the difference should be between lambda and proc, but in 1.8.3 the difference is between Proc.new and proc, does this mean that there is an issue with Kernel.proc in 1.8.3? and i would also suggest changing the api-documation, allthough i don't know exactly i shall proceed to propose such a change. for Kernel.lambda it currently states: Equivalent to Proc.new, except the resulting Proc objects check the number of parameters passed when called. a better phrasing i think would be: Equivalent to Proc.new, except the resulting Proc objects have method-like-parameter-passing instead of the normal expression-like-parameter-passing. or something along those lines. personally i would think it'd be nice with something more explaining the differences of the two, but the api-documentation might not be the proper place for making this clear. !g