ruby-changes:22972
From: shugo <ko1@a...>
Date: Thu, 15 Mar 2012 01:00:41 +0900 (JST)
Subject: [ruby-changes:22972] shugo:r35021 (trunk): * enumerator.c (enumerable_lazy): fix the documentation of
shugo 2012-03-15 01:00:30 +0900 (Thu, 15 Mar 2012) New Revision: 35021 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35021 Log: * enumerator.c (enumerable_lazy): fix the documentation of Enumerable#lazy. Modified files: trunk/ChangeLog trunk/enumerator.c Index: ChangeLog =================================================================== --- ChangeLog (revision 35020) +++ ChangeLog (revision 35021) @@ -1,3 +1,8 @@ +Thu Mar 15 00:58:04 2012 Shugo Maeda <shugo@r...> + + * enumerator.c (enumerable_lazy): fix the documentation of + Enumerable#lazy. + Wed Mar 14 22:01:06 2012 Shugo Maeda <shugo@r...> * enumerator.c (lazy_init_iterator): break when Qundef is returned Index: enumerator.c =================================================================== --- enumerator.c (revision 35020) +++ enumerator.c (revision 35021) @@ -1209,12 +1209,13 @@ * 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 @@ * } * } * 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/