diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-19 06:41:02 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-19 06:41:02 +0000 |
commit | 831898bd9971ec5997267226417ce0ce6f76ecd7 (patch) | |
tree | 164c3b4e8b5c6427965d336e242571c4d586ff51 /enumerator.c | |
parent | 0d1c2268a81268e0026230d4d55cf73931665fcd (diff) | |
download | ruby-831898bd9971ec5997267226417ce0ce6f76ecd7.tar.gz |
* 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
Diffstat (limited to 'enumerator.c')
-rw-r--r-- | enumerator.c | 6 |
1 files changed, 4 insertions, 2 deletions
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 */ |