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

ruby-changes:23040

From: shugo <ko1@a...>
Date: Mon, 19 Mar 2012 15:41:12 +0900 (JST)
Subject: [ruby-changes:23040] shugo:r35090 (trunk): * enumerator.c (enumerable_lazy): add an example of take and first

shugo	2012-03-19 15:41:02 +0900 (Mon, 19 Mar 2012)

  New Revision: 35090

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

  Log:
    * enumerator.c (enumerable_lazy): add an example of take and first
      to the documentation.  [ruby-core:43344] [Bug #6158]
      add the description of the behavior when a block is given to zip
      or cycle.

  Modified files:
    trunk/ChangeLog
    trunk/enumerator.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35089)
+++ ChangeLog	(revision 35090)
@@ -1,3 +1,10 @@
+Mon Mar 19 15:36:41 2012  Shugo Maeda  <shugo@r...>
+
+	* enumerator.c (enumerable_lazy): add an example of take and first
+	  to the documentation.  [ruby-core:43344] [Bug #6158]
+	  add the description of the behavior when a block is given to zip
+	  or cycle.
+
 Mon Mar 19 15:20:53 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* compile.c (iseq_specialized_instruction): DRY and replace chain
@@ -150,7 +157,7 @@
 
 Thu Mar 15 16:37:38 2012  Shugo Maeda  <shugo@r...>
 
-	* enumerator.c (enumerator_lazy): added cycle to the documentation.
+	* enumerator.c (enumerable_lazy): added cycle to the documentation.
 
 Thu Mar 15 15:37:42 2012  Nobuyoshi Nakada  <nobu@r...>
 
Index: enumerator.c
===================================================================
--- enumerator.c	(revision 35089)
+++ enumerator.c	(revision 35090)
@@ -1244,7 +1244,8 @@
  * Returns a lazy enumerator, whose methods map/collect,
  * flat_map/collect_concat, select/find_all, reject, grep, zip, take,
  * take_while, drop, drop_while, and cycle enumerate values only on an
- * as-needed basis.
+ * as-needed basis.  However, if a block is given to zip or cycle, values
+ * are enumerated immediately.
  *
  * === Example
  *
@@ -1262,7 +1263,8 @@
  *     }
  *   end
  *   # show first ten pythagorean triples
- *   p pythagorean_triples.take(10).force
+ *   p pythagorean_triples.take(10).force # take is lazy, so force is needed
+ *   p pythagorean_triples.first(10)      # first is eager
  *   # show pythagorean triples less than 100
  *   p pythagorean_triples.take_while { |*, z| z < 100 }.force
  */

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

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