Hi,
In message "Re: questions re Method#to_proc"
on Tue, 18 Apr 2006 17:39:51 +0900, Eli Bendersky <eliben / gmail.com> writes:
|Additionally, the following, IMHO demostrates a very surprising and
|unnatural behavior of to_proc:
|
|def foo(arr)
| puts "Got an array with #{arr.length} elements"
|end
|
|# works correctly
|foo([4, 5, 6])
|
|foo_proc = method(:foo).to_proc
|
|# throws an ArgumentError: 3 for 1
|foo_proc.call([4, 5, 6])
|
|# works correctly
|foo_proc.call([[4, 5, 6]])
This issue will be solved in the future version (1.9), which should
give you the following result:
Got an array with 3 elements
Got an array with 3 elements
Got an array with 1 elements
matz.