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

ruby-changes:2558

From: ko1@a...
Date: 30 Nov 2007 19:08:31 +0900
Subject: [ruby-changes:2558] matz - Ruby:r14049 (trunk): * enum.c (enum_count): precise argument number check.

matz	2007-11-30 19:08:03 +0900 (Fri, 30 Nov 2007)

  New Revision: 14049

  Modified files:
    trunk/ChangeLog
    trunk/enum.c

  Log:
    * enum.c (enum_count): precise argument number check.
    
    * enum.c (enum_count): return Enumerator if no block given.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14049&r2=14048
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enum.c?r1=14049&r2=14048

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14048)
+++ ChangeLog	(revision 14049)
@@ -1,3 +1,9 @@
+Fri Nov 30 19:05:55 2007  Yukihiro Matsumoto  <matz@r...>
+
+	* enum.c (enum_count): precise argument number check.
+
+	* enum.c (enum_count): return Enumerator if no block given.
+
 Fri Nov 30 16:42:50 2007  Yukihiro Matsumoto  <matz@r...>
 
 	* enum.c (enum_take_while): returns Enumerator if no block given.
Index: enum.c
===================================================================
--- enum.c	(revision 14048)
+++ enum.c	(revision 14049)
@@ -114,12 +114,17 @@
 	rb_block_call(obj, id_each, 0, 0, count_i, (VALUE)&args);
 	return INT2NUM(args[1]);
     }
-    else {
-	long n = 0;
+    else if (argc == 0) {
+	long n;
 
+	RETURN_ENUMERATOR(obj, 0, 0);
+	n = 0;
 	rb_block_call(obj, id_each, 0, 0, count_iter_i, (VALUE)&n);
 	return INT2NUM(n);
     }
+    else {
+	rb_scan_args(argc, argv, "1", &argv[0]);
+    }
 }
 
 static VALUE

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

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