1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
shugo 2012-03-19 06:41:02 +00:00
parent 0d1c2268a8
commit 831898bd99
2 changed files with 12 additions and 3 deletions

View file

@ -1,3 +1,10 @@
Mon Mar 19 15:36:41 2012 Shugo Maeda <shugo@ruby-lang.org>
* 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@ruby-lang.org> Mon Mar 19 15:20:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* compile.c (iseq_specialized_instruction): DRY and replace chain * compile.c (iseq_specialized_instruction): DRY and replace chain
@ -150,7 +157,7 @@ Thu Mar 15 17:45:27 2012 Shugo Maeda <shugo@ruby-lang.org>
Thu Mar 15 16:37:38 2012 Shugo Maeda <shugo@ruby-lang.org> Thu Mar 15 16:37:38 2012 Shugo Maeda <shugo@ruby-lang.org>
* 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@ruby-lang.org> Thu Mar 15 15:37:42 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>

View file

@ -1244,7 +1244,8 @@ lazy_initialize(int argc, VALUE *argv, VALUE self)
* Returns a lazy enumerator, whose methods map/collect, * Returns a lazy enumerator, whose methods map/collect,
* flat_map/collect_concat, select/find_all, reject, grep, zip, take, * flat_map/collect_concat, select/find_all, reject, grep, zip, take,
* take_while, drop, drop_while, and cycle enumerate values only on an * 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 * === Example
* *
@ -1262,7 +1263,8 @@ lazy_initialize(int argc, VALUE *argv, VALUE self)
* } * }
* end * end
* # show first ten pythagorean triples * # 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 * # show pythagorean triples less than 100
* p pythagorean_triples.take_while { |*, z| z < 100 }.force * p pythagorean_triples.take_while { |*, z| z < 100 }.force
*/ */