[前][次][番号順一覧][スレッド一覧]

ruby-changes:33159

From: marcandre <ko1@a...>
Date: Sun, 2 Mar 2014 10:55:52 +0900 (JST)
Subject: [ruby-changes:33159] marcandRe: r45238 (trunk): * proc.c: Complete rdoc of Proc#arity regarding keyword arguments.

marcandre	2014-03-02 10:55:49 +0900 (Sun, 02 Mar 2014)

  New Revision: 45238

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45238

  Log:
    * proc.c: Complete rdoc of Proc#arity regarding keyword arguments.
      See #8072 and #9299.

  Modified files:
    trunk/proc.c
Index: proc.c
===================================================================
--- proc.c	(revision 45237)
+++ proc.c	(revision 45238)
@@ -846,6 +846,8 @@ rb_proc_call_with_block(VALUE self, int https://github.com/ruby/ruby/blob/trunk/proc.c#L846
  *  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,
+ *  that argument being mandatory if any keyword argument is mandatory.
  *  A <code>proc</code> with no argument declarations
  *  is the same a block declaring <code>||</code> as its arguments.
  *
@@ -857,6 +859,8 @@ rb_proc_call_with_block(VALUE self, int https://github.com/ruby/ruby/blob/trunk/proc.c#L859
  *     proc { |*a| }.arity            #=> -1
  *     proc { |a, *b| }.arity         #=> -2
  *     proc { |a, *b, c| }.arity      #=> -3
+ *     proc { |x:, y:, z:0| }.arity   #=>  1
+ *     proc { |*a, x:, y:0| }.arity   #=> -2
  *
  *     proc   { |x=0| }.arity         #=>  0
  *     lambda { |x=0| }.arity         #=> -1
@@ -868,6 +872,8 @@ rb_proc_call_with_block(VALUE self, int https://github.com/ruby/ruby/blob/trunk/proc.c#L872
  *     lambda { |x, y=0| }.arity      #=> -2
  *     proc   { |(x, y), z=0| }.arity #=>  1
  *     lambda { |(x, y), z=0| }.arity #=> -2
+ *     proc   { |a, x:0, y:0| }.arity #=>  1
+ *     lambda { |a, x:0, y:0| }.arity #=> -2
  */
 
 static VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]