Issue #5694 has been updated by marcandre (Marc-Andre Lafortune).

Status changed from Closed to Open
Assignee changed from nobu (Nobuyoshi Nakada) to matz (Yukihiro Matsumoto)

Hi,

akr (Akira Tanaka) wrote:
> We discussed this issue at a developer meeting.
> We have consensus that lambda {...}.arity should behave as Method#arity.

Good.

> Note that we should not change proc {...}.arity.

I missed this the first time.

Why?

Lambdas and Proc have the same `arity` for the same signature. Why introduce a difference? Same signature => same arity is simplest, no?

We just confirmed that arity = -n -1 means at least n parameters are asked, but more are accepted (not sure how many). Why would this be different for Proc?

Why would a method defined from a Proc not always have the same arity as that block?

----------------------------------------
Bug #5694: Proc#arity doesn't take optional arguments into account. 
https://bugs.ruby-lang.org/issues/5694#change-28153

Author: marcandre (Marc-Andre Lafortune)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 
ruby -v: -


Currently:

    ->(foo = 42){}.arity # => 0, should be -1

This is contrary to the documentation and to what we should expect from the equivalent method definition.

Fixed in trunk, requesting backport for the 1.9 line.



-- 
http://bugs.ruby-lang.org/