ruby-changes:58357
From: Yusuke <ko1@a...>
Date: Tue, 22 Oct 2019 19:40:16 +0900 (JST)
Subject: [ruby-changes:58357] fac4339a12 (master): NEWS: add an example for Lazy#eager
https://git.ruby-lang.org/ruby.git/commit/?id=fac4339a12 From fac4339a1273df64fe764579f0d3ccccf64b74b4 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Tue, 22 Oct 2019 19:39:42 +0900 Subject: NEWS: add an example for Lazy#eager diff --git a/NEWS b/NEWS index f29669a..8165b87 100644 --- a/NEWS +++ b/NEWS @@ -251,6 +251,15 @@ Enumerator:: https://github.com/ruby/ruby/blob/trunk/NEWS#L251 * Added Enumerator::Lazy#eager that generates a non-lazy enumerator from a lazy enumerator. [Feature #15901] + a = %w(foo bar baz) + e = a.lazy + .map {|x| p [x, :upcase]; x.upcase } + .map {|x| p [x, :add_bang]; x + "!" } + .eager + p e.next #=> ["foo", :upcase], ["FOO", :add_bang], "FOO!" + p e.next #=> ["bar", :upcase], ["BAR", :add_bang], "BAR!" + p e.next #=> ["baz", :upcase], ["BAZ", :add_bang], "BAZ!" + * Added Enumerator::Yielder#to_proc so that a Yielder object can be directly passed to another method as a block argument. [Feature #15618] -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/