From: Sam Roberts Date: 2004-11-15T01:29:21+09:00 Subject: Re: [DOCBUG] Proc#arity Quoteing matz@ruby-lang.org, on Sun, Nov 14, 2004 at 06:43:32PM +0900: > In message "Re: [DOCBUG] Proc#arity" > on Sun, 14 Nov 2004 18:19:25 +0900, Mauricio Fern�ndez writes: > |> An inconsistency in the docs for Proc#arity ? Here's what ri says: > |> > |> arguments. A +proc+ with no argument declarations returns -1, as it > |> can accept (and ignore) an arbitrary number of parameters. > > | * eval.c (proc_arity): arity is now defined as number of > | parameters that would not be ignored. i.e. Proc.new{}.arity > | returns zero. update test suites too. > > And lambda{}.call(1) should have made to raise exception. I will fix > this. Could somebody update the document? If I understand this correctly, the docs should now say something like the below? Cheers, Sam Index: eval.c =================================================================== RCS file: /src/ruby/eval.c,v retrieving revision 1.616.2.68 diff -u -r1.616.2.68 eval.c --- eval.c 12 Nov 2004 06:06:12 -0000 1.616.2.68 +++ eval.c 14 Nov 2004 16:26:35 -0000 @@ -8207,15 +8207,14 @@ * call-seq: * prc.arity -> fixnum * - * Returns the number of arguments required by the block. If the block + * Returns the number of arguments that would not be ignored. If the block * is declared to take no arguments, returns 0. If the block is known * to take exactly n arguments, returns n. If the block has optional * arguments, return -n-1, where n is the number of mandatory - * arguments. A proc with no argument declarations - * returns -1, as it can accept (and ignore) an arbitrary number of - * parameters. + * arguments. A proc with no argument declarations + * is handled like a block declaring || as its arguments. * - * Proc.new {}.arity #=> -1 + * Proc.new {}.arity #=> 0 * Proc.new {||}.arity #=> 0 * Proc.new {|a|}.arity #=> 1 * Proc.new {|a,b|}.arity #=> 2