Let's say I have two enumerators, enum1
and enum2
that must be lazily iterated through (because they have side effects). How do I construct a third enumerator enum3
where enum3.each{|x| x}
would lazily return the equivalent of enum1 + enum2
?
In my real world use case, I'm streaming in two files, and need to stream out the concatenation.
flat_map
solution. Even though we'd already verified the laziness offlat_map
, this didn't occur to us, to use it as a lazy append! :) – Sottish