From: Yehuda Katz Date: 2008-02-14T18:58:30+09:00 Subject: Re: An Masgn of 1 I understand the behavior, but I don't understand the *rationale* for the behavior. Is the existence of {|x,| } intentional, or a parsing artifact? I can fully understand the behavior of {|x,y| } in both block and lambda context, but {|x,| } behaves rather strangely (as you documented). So again, is {|x,| } intentional? -- Yehuda On Feb 13, 2008, at 9:57 PM, Tanaka Akira wrote: > In article <47B3990A.9020709@dan42.com>, > Daniel DeLorme writes: > >> So I think it has to do with blocks using multiple-assignment >> semantics >> and lambdas using function-arguments semantics. Since there is no >> such >> thing as "def foo(x,)" then "lambda{|x,|" is considered as the >> equivalent of "def foo(x)". Do I have it wrong? > > Blocks are blocks. It is neigher lambda nor multiple > assigment. > > For example, > lambda {|x| p x }.call(1,2,3) causes ArgumentError and > x = 1,2,3 assignes x to [1,2,3] but > def m() yield 1,2,3 end; m {|x| p x } binds x to 1. > (ruby 1.9.0 (2008-02-13 revision 15455) [i686-linux]) > > I wrote the semantics as a test: > TestRubyYieldGen in test/ruby/test_yield.rb. > -- > Tanaka Akira >