diff options
author | stomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-02 20:21:15 +0000 |
---|---|---|
committer | stomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-02 20:21:15 +0000 |
commit | 81395f22f3a95ba06754e57f90ee6e7311279e8c (patch) | |
tree | 07e0f0a07c4f139a8389c29cc988ea296873ba7f | |
parent | ab149d1689ba1ce33caeb0887683cf1a82e571f5 (diff) | |
download | ruby-81395f22f3a95ba06754e57f90ee6e7311279e8c.tar.gz |
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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | proc.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -922,7 +922,7 @@ rb_proc_call_with_block(VALUE self, int argc, const VALUE *argv, VALUE passed_pr * 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_entry_t *me) * 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_entry_t *me) * 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_entry_t *me) * 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 |