From: Yukihiro Matsumoto Date: 2011-12-09T13:39:05+09:00 Subject: [ruby-core:41560] Re: [ruby-trunk - Bug #5730][Open] Optinal block parameters assigns wrong Hi, In message "Re: [ruby-core:41559] Re: [ruby-trunk - Bug #5730][Open] Optinal block parameters assigns wrong" on Fri, 9 Dec 2011 09:36:00 +0900, Tanaka Akira writes: |If we break consistency between method invocation and block invocation, |I think concrete usefulness should be shown. OK, the point is when * block is not a lambda * yielded value is an array we expand the value for the sake of compatibility, i.e. def foo(&block) block.call([1,2]) end foo{|k,v| p [k,v] # gives [1,2] } and even when some parameters are optional: foo{|k,v=6| p [k,v] # gives [1,2] too } but Ruby do NOT expand the value when all parameters are optional: foo{|k=5,v=6| p [k,v] # gives [[1,2],6] } |I think the consistency explains current behavior. From above examples, I consider the current behavior is NOT consistent at all, under some condition. The example from Aaron in [ruby-core:41558] uses a proc from method object, which is not the target of this issue. I expect the following behavior foo(&->(k=6,v=8){p [k,v]}) # => [[1,2],6] I don't think fixing this issue does not break any consistency. matz.