Project

General

Profile

Backport #3938 ยป methodarity.rb

ruby script to minimally reproduce the incorrect behavior - Ethan (Ethan -), 10/13/2010 03:19 AM

 
1
def Object.onearg(arg)
2
  arg
3
end
4
amethod = Object.method(:onearg)
5
aproc = proc{|arg| arg}
6

    
7
require 'pp'
8
pp([[1, 2]].detect(&aproc))   # works because proc works correctly
9
pp([[1]].detect(&amethod))    # works because arity happens to be the same as [1].size
10
pp([[1, 2]].detect(&amethod)) # doesn't work because arity isn't the asme as [1, 2].size