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]
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]
On Sun, May 07, 2006 at 01:11:44PM +0900, Logan C. wrote:
It’s not a bug it’s a feature:
proc { || } has arity 0, proc {} takes any number of args and ignores
them.
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)
On May 6, 2006, at 11:03 PM, polypus wrote:
–
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.
“M” == Mauricio F. [email protected] writes:
M> lambda{ }.arity # => 0
M> lambda{}.call(1,2,3)
M> # ~> -:4: wrong number of arguments (3 for 0) (ArgumentError)
M> # ~> 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 [email protected]
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs