ruby-changes:48504
From: stomar <ko1@a...>
Date: Fri, 3 Nov 2017 05:21:19 +0900 (JST)
Subject: [ruby-changes:48504] stomar:r60619 (trunk): proc.c: further improve docs for {Method, Proc}#arity
stomar 2017-11-03 05:21:15 +0900 (Fri, 03 Nov 2017) New Revision: 60619 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60619 Log: proc.c: further improve docs for {Method,Proc}#arity * proc.c: [DOC] fix grammar in docs for {Method,Proc}#arity; for Method#arity, move special case of methods written in C to the end of the description, fix a typo in a method name, and add an example for required arguments with an optional keyword argument. Modified files: trunk/proc.c Index: proc.c =================================================================== --- proc.c (revision 60618) +++ proc.c (revision 60619) @@ -922,7 +922,7 @@ rb_proc_call_with_block(VALUE self, int https://github.com/ruby/ruby/blob/trunk/proc.c#L922 * number of mandatory arguments, with the exception for blocks that * are not lambdas and have only a finite number of optional arguments; * in this latter case, returns n. - * Keywords arguments will considered as a single additional argument, + * Keyword arguments will be considered as a single additional argument, * that argument being mandatory if any keyword argument is mandatory. * A <code>proc</code> with no argument declarations * is the same as a block declaring <code>||</code> as its arguments. @@ -2354,11 +2354,11 @@ rb_method_entry_arity(const rb_method_en https://github.com/ruby/ruby/blob/trunk/proc.c#L2354 * Returns an indication of the number of arguments accepted by a * method. Returns a nonnegative integer for methods that take a fixed * number of arguments. For Ruby methods that take a variable number of - * arguments, returns -n-1, where n is the number of required - * arguments. For methods written in C, returns -1 if the call takes a - * variable number of arguments. - * Keywords arguments will considered as a single additional argument, + * arguments, returns -n-1, where n is the number of required arguments. + * Keyword arguments will be considered as a single additional argument, * that argument being mandatory if any keyword argument is mandatory. + * For methods written in C, returns -1 if the call takes a + * variable number of arguments. * * class C * def one; end @@ -2367,9 +2367,10 @@ rb_method_entry_arity(const rb_method_en https://github.com/ruby/ruby/blob/trunk/proc.c#L2367 * def four(a, b); end * def five(a, b, *c); end * def six(a, b, *c, &d); end - * def seven(x:, y:); end - * def eighth(x:, y:, **z); end - * def nine(*a, x:, y:); end + * def seven(a, b, x:0); end + * def eight(x:, y:); end + * def nine(x:, y:, **z); end + * def ten(*a, x:, y:); end * end * c = C.new * c.method(:one).arity #=> 0 @@ -2378,9 +2379,10 @@ rb_method_entry_arity(const rb_method_en https://github.com/ruby/ruby/blob/trunk/proc.c#L2379 * c.method(:four).arity #=> 2 * c.method(:five).arity #=> -3 * c.method(:six).arity #=> -3 - * c.method(:seven).arity #=> 1 - * c.method(:eighth).arity #=> 1 - * c.method(:nine).arity #=> -2 + * c.method(:seven).arity #=> -3 + * c.method(:eight).arity #=> 1 + * c.method(:nine).arity #=> 1 + * c.method(:ten).arity #=> -2 * * "cat".method(:size).arity #=> 0 * "cat".method(:replace).arity #=> 1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/