Bug #3552
closedMap doesn't accept multiple arguments for its block converted from lambda
Description
=begin
Following raises wrong number of arguments error:
irb(main):001:0> l=lambda{|x,y| x+y}
=> #<Proc:0x2b57820@(irb):1 (lambda)>
irb(main):002:0> [[1,2],[3,4]].map(&l)
ArgumentError: wrong number of arguments (1 for 2)
from (irb):2:in map' from (irb):2 from C:/Ruby191/bin/irb:12:in '
=end
Updated by judofyr (Magnus Holm) over 15 years ago
=begin
That's not a bug. lambda behaves differently from Proc.new/proc:
l = lambda { |x,y| x + y }
=> #<Proc:0x0000010183da90@(irb):1 (lambda)>
l.lambda?
=> true
[[1,2],[3,4]].map(&l)
ArgumentError: wrong number of arguments (1 for 2)
from (irb):1:inblock in irb_binding' from (irb):3:inmap'
from (irb):3
from /Users/magnus/.rvm/rubies/ruby-1.9.2-preview3/bin/irb:17:in `'
l = proc { |x,y| x + y }
=> #Proc:0x00000101829860@(irb):4
l.lambda?
=> false
[[1,2],[3,4]].map(&l)
=> [3, 7]
// Magnus Holm
On Thu, Jul 8, 2010 at 23:47, aduket aduket redmine@ruby-lang.org wrote:
Bug #3552: Map doesn't accept multiple arguments for its block converted from lambda
http://redmine.ruby-lang.org/issues/show/3552Author: aduket aduket
Status: Open, Priority: Normal
ruby -v: 1.9.1Following raises wrong number of arguments error:
irb(main):001:0> l=lambda{|x,y| x+y}
=> #<Proc:0x2b57820@(irb):1 (lambda)>
irb(main):002:0> [[1,2],[3,4]].map(&l)
ArgumentError: wrong number of arguments (1 for 2)
from (irb):2:inmap' from (irb):2 from C:/Ruby191/bin/irb:12:in'
=end
Updated by shyouhei (Shyouhei Urabe) over 15 years ago
- Status changed from Open to Rejected
=begin
Designed behaviour.
=end