зеркало из https://github.com/github/ruby.git
NEWS: Fix the example of Lazy#eager
This commit is contained in:
Родитель
fac4339a12
Коммит
02aadf1032
10
NEWS
10
NEWS
|
@ -252,13 +252,9 @@ 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!"
|
||||
e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
|
||||
p e.class #=> Enumerator
|
||||
p e.map {|x| x + "?" } #=> ["FOO!?", "BAR!?", "BAZ!?"]
|
||||
|
||||
* Added Enumerator::Yielder#to_proc so that a Yielder object
|
||||
can be directly passed to another method as a block
|
||||
|
|
Загрузка…
Ссылка в новой задаче