NEWS: Fix the example of Lazy#eager

This commit is contained in:
Yusuke Endoh 2019-10-22 19:46:44 +09:00
parent fac4339a12
commit 02aadf1032

10
NEWS
View File

@ -252,13 +252,9 @@ Enumerator::
from a lazy enumerator. [Feature #15901] from a lazy enumerator. [Feature #15901]
a = %w(foo bar baz) a = %w(foo bar baz)
e = a.lazy e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
.map {|x| p [x, :upcase]; x.upcase } p e.class #=> Enumerator
.map {|x| p [x, :add_bang]; x + "!" } p e.map {|x| x + "?" } #=> ["FOO!?", "BAR!?", "BAZ!?"]
.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 * Added Enumerator::Yielder#to_proc so that a Yielder object
can be directly passed to another method as a block can be directly passed to another method as a block