From 831898bd9971ec5997267226417ce0ce6f76ecd7 Mon Sep 17 00:00:00 2001 From: shugo Date: Mon, 19 Mar 2012 06:41:02 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 ++++++++- enumerator.c | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54393b7830..71f5470046 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Mar 19 15:36:41 2012 Shugo Maeda + + * 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 * compile.c (iseq_specialized_instruction): DRY and replace chain @@ -150,7 +157,7 @@ Thu Mar 15 17:45:27 2012 Shugo Maeda Thu Mar 15 16:37:38 2012 Shugo Maeda - * 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 diff --git a/enumerator.c b/enumerator.c index a83f3ca61e..9484f495cc 100644 --- a/enumerator.c +++ b/enumerator.c @@ -1244,7 +1244,8 @@ lazy_initialize(int argc, VALUE *argv, VALUE self) * 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 @@ lazy_initialize(int argc, VALUE *argv, VALUE self) * } * 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 */