Behavior of proc { || } on 1.9

Is this expected behavior?

cout@bean:~$ ruby -v -e ‘proc { || }.call 42’
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
-e:1: wrong number of arguments (1 for 0) (ArgumentError)
from -e:1:in `call’
from -e:1
cout@bean:~$ ruby1.9 -v -e ‘proc { || }.call 42’
ruby 1.9.0 (2007-05-26 patchlevel 0) [i686-linux]

On May 27, 8:59 pm, Paul B. [email protected] wrote:

Is this expected behavior?

cout@bean:~$ ruby -v -e ‘proc { || }.call 42’
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
-e:1: wrong number of arguments (1 for 0) (ArgumentError)
from -e:1:in `call’
from -e:1
cout@bean:~$ ruby1.9 -v -e ‘proc { || }.call 42’
ruby 1.9.0 (2007-05-26 patchlevel 0) [i686-linux]

1.9 gives no such error?
Seems as 1.8.6 is right on, yet on my system, under 1.8.5 (patchlevel
35):

irb(main):001:0> Proc.new{|a| p a}.call 69,70
(irb):9: warning: multiple values for a block parameter (2 for 1)
from (irb):9
[69, 70]
=> nil
irb(main):002:0> Proc.new{|a,b| p a}.call 69,70,71
69
=> nil

Considering b isnt optional, i.e. specified as “*b” (where b[1] ==
71)
Shouldn’t this raise a 3 for 2 warning?

irb(main):003:0> def what(a,b)
irb(main):004:1> p a
irb(main):005:1> p b
irb(main):006:1> end
=> nil
irb(main):007:0> what(1,2,3)
ArgumentError: wrong number of arguments (3 for 2)
from (irb):5:in `what’
from (irb):5
from :0

I understand that there are differences between a function definition
and a Proc object, but why are there differences in the way they treat
their arguments?

On 5/27/07, Paul B. [email protected] wrote:

Is this expected behavior?

cout@bean:~$ ruby -v -e ‘proc { || }.call 42’
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
-e:1: wrong number of arguments (1 for 0) (ArgumentError)
from -e:1:in `call’
from -e:1
cout@bean:~$ ruby1.9 -v -e ‘proc { || }.call 42’
ruby 1.9.0 (2007-05-26 patchlevel 0) [i686-linux]

In 1.9 proc behaves more like Proc.new IIRC.

Brian.