mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
NEWS: add an example for Lazy#eager
This commit is contained in:
parent
0e735b218f
commit
fac4339a12
1 changed files with 9 additions and 0 deletions
9
NEWS
9
NEWS
|
@ -251,6 +251,15 @@ Enumerator::
|
||||||
* Added Enumerator::Lazy#eager that generates a non-lazy enumerator
|
* Added Enumerator::Lazy#eager that generates a non-lazy enumerator
|
||||||
from a lazy enumerator. [Feature #15901]
|
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
|
* 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
|
||||||
argument. [Feature #15618]
|
argument. [Feature #15618]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue