From 831898bd9971ec5997267226417ce0ce6f76ecd7 Mon Sep 17 00:00:00 2001 From: shugo Date: Mon, 19 Mar 2012 06:41:02 +0000 Subject: * 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 --- enumerator.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'enumerator.c') 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 */ -- cgit v1.2.3