diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | enumerator.c | 12 |
2 files changed, 13 insertions, 4 deletions
@@ -1,3 +1,8 @@ +Thu Mar 15 00:58:04 2012 Shugo Maeda <shugo@ruby-lang.org> + + * enumerator.c (enumerable_lazy): fix the documentation of + Enumerable#lazy. + Wed Mar 14 22:01:06 2012 Shugo Maeda <shugo@ruby-lang.org> * enumerator.c (lazy_init_iterator): break when Qundef is returned diff --git a/enumerator.c b/enumerator.c index ab0c39e6c1..c4d18ac076 100644 --- a/enumerator.c +++ b/enumerator.c @@ -1209,12 +1209,13 @@ lazy_initialize(VALUE self, VALUE obj) * e.lazy -> lazy_enumerator * * Returns a lazy enumerator, whose methods map/collect, - * flat_map/collect_concat, select/find_all, reject, and grep call blocks - * only on an as-needed basis. + * flat_map/collect_concat, select/find_all, reject, grep, zip, take, + * take_while, drop, and drop_while enumerate values only on an as-needed + * basis. * * === Example * - * The following program shows all pythagorean triples less than 100: + * The following program finds pythagorean triples: * * def pythagorean_triples * (1..Float::INFINITY).lazy.flat_map {|z| @@ -1227,7 +1228,10 @@ lazy_initialize(VALUE self, VALUE obj) * } * } * end - * p pythagorean_triples.take_while { |x, y, z| z < 100 } + * # show first ten pythagorean triples + * p pythagorean_triples.take(10).force + * # show pythagorean triples less than 100 + * p pythagorean_triples.take_while { |*, z| z < 100 }.force */ static VALUE enumerable_lazy(VALUE obj) |