aboutsummaryrefslogtreecommitdiffstats
path: root/proc.c
diff options
context:
space:
mode:
authorstomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-02 20:20:11 +0000
committerstomar <stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-02 20:20:11 +0000
commitfa7baeef43210b4828d8806ddea11ff81a4b2ead (patch)
tree5c04a4912ffffc3d77eff37369d5a39c35846f39 /proc.c
parent15ad237b5f05696d18937b7cfeb7991a44a75e68 (diff)
downloadruby-fa7baeef43210b4828d8806ddea11ff81a4b2ead.tar.gz
proc.c: improve docs for {Method,Proc}#arity
* proc.c: [DOC] improve Method#arity documentation to match with Proc#arity, mentioning keyword arguments; also make Proc#arity examples more consistent in the naming of keyword arguments. Patch by Nikita Misharin (TheSmartnik). [Fix GH-1735] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/proc.c b/proc.c
index 164b8bf570..52421fc044 100644
--- a/proc.c
+++ b/proc.c
@@ -938,16 +938,16 @@ rb_proc_call_with_block(VALUE self, int argc, const VALUE *argv, VALUE passed_pr
* proc { |x:, y:, z:0| }.arity #=> 1
* proc { |*a, x:, y:0| }.arity #=> -2
*
- * proc { |x=0| }.arity #=> 0
- * lambda { |x=0| }.arity #=> -1
- * proc { |x=0, y| }.arity #=> 1
- * lambda { |x=0, y| }.arity #=> -2
- * proc { |x=0, y=0| }.arity #=> 0
- * lambda { |x=0, y=0| }.arity #=> -1
- * proc { |x, y=0| }.arity #=> 1
- * lambda { |x, y=0| }.arity #=> -2
- * proc { |(x, y), z=0| }.arity #=> 1
- * lambda { |(x, y), z=0| }.arity #=> -2
+ * proc { |a=0| }.arity #=> 0
+ * lambda { |a=0| }.arity #=> -1
+ * proc { |a=0, b| }.arity #=> 1
+ * lambda { |a=0, b| }.arity #=> -2
+ * proc { |a=0, b=0| }.arity #=> 0
+ * lambda { |a=0, b=0| }.arity #=> -1
+ * proc { |a, b=0| }.arity #=> 1
+ * lambda { |a, b=0| }.arity #=> -2
+ * proc { |(a, b), c=0| }.arity #=> 1
+ * lambda { |(a, b), c=0| }.arity #=> -2
* proc { |a, x:0, y:0| }.arity #=> 1
* lambda { |a, x:0, y:0| }.arity #=> -2
*/
@@ -2357,6 +2357,8 @@ rb_method_entry_arity(const rb_method_entry_t *me)
* 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,
+ * that argument being mandatory if any keyword argument is mandatory.
*
* class C
* def one; end
@@ -2365,6 +2367,9 @@ 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
* end
* c = C.new
* c.method(:one).arity #=> 0
@@ -2373,6 +2378,9 @@ 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
*
* "cat".method(:size).arity #=> 0
* "cat".method(:replace).arity #=> 1