p = proc {}
p.arity -> -1
shouldn't that be returning 0?
btw p = proc { |*a| } gives me -1 like it should.
ruby 1.8.4 (2005-12-24) [i686-linux]
···
--
Posted via http://www.ruby-forum.com/.
p = proc {}
p.arity -> -1
shouldn't that be returning 0?
btw p = proc { |*a| } gives me -1 like it should.
ruby 1.8.4 (2005-12-24) [i686-linux]
--
Posted via http://www.ruby-forum.com/.
It's not a bug it's a feature:
proc { || } has arity 0, proc {} takes any number of args and ignores them.
On May 6, 2006, at 11:03 PM, polypus wrote:
p = proc {}
p.arity -> -1shouldn't that be returning 0?
btw p = proc { |*a| } gives me -1 like it should.
ruby 1.8.4 (2005-12-24) [i686-linux]
-- Posted via http://www.ruby-forum.com/\.
Note that lambda{}.arity == 0 in 1.9:
RUBY_VERSION # => "1.9.0"
RUBY_RELEASE_DATE # => "2006-05-01"
lambda{ }.arity # => 0
lambda{}.call(1,2,3)
# ~> -:4: wrong number of arguments (3 for 0) (ArgumentError)
# ~> from -:4
On Sun, May 07, 2006 at 01:11:44PM +0900, Logan Capaldo wrote:
On May 6, 2006, at 11:03 PM, polypus wrote:
>p = proc {}
>p.arity -> -1
>
>shouldn't that be returning 0?
>
>btw p = proc { |*a| } gives me -1 like it should.
>
>ruby 1.8.4 (2005-12-24) [i686-linux]It's not a bug it's a feature:
proc { || } has arity 0, proc {} takes any number of args and ignores
them.
--
Mauricio Fernandez - http://eigenclass.org - singular Ruby
lambda{ }.arity # => 0
lambda{}.call(1,2,3)
# ~> -:4: wrong number of arguments (3 for 0) (ArgumentError)
# ~> from -:4
moulon% ruby -ve 'p proc{}.arity; p proc{}.call(1,2,3)'
ruby 1.9.0 (2006-05-01) [i686-linux]
0
nil
moulon%
Guy Decoux
Hi,
In message "Re: Proc#arity bug?" on Sun, 7 May 2006 18:04:16 +0900, ts <decoux@moulon.inra.fr> writes:
moulon% ruby -ve 'p proc{}.arity; p proc{}.call(1,2,3)'
ruby 1.9.0 (2006-05-01) [i686-linux]
0
nil
Hmm, indeed it's inconsistent. I will fix, either arity to return -1,
or call to raise ArgumentError.
matz.