https://kotlinlang.org logo
#announcements
Title
# announcements
e

eekboom

10/29/2019, 4:34 PM
Is there something similar to Java’s Stream.Builder? Something that I can pass around and let code add values to and finally create a Sequence? I mean I can always use a mutable list, but I like the smaller API of Stream.Builder.
o

octylFractal

10/29/2019, 4:51 PM
yes, just use the
sequence {}
block
instead of "passing it down", have other code return their own Sequence object and use
yieldAll
. They're lazily evaluated, so it's pretty cheap to do so
e

eekboom

10/29/2019, 4:57 PM
Hm, thanks, When converting a large-ish Java code base this feels like too much refactoring on top of the already existing conversion. I guess for now I’ll stick with mutable list - or maybe create my own SequenceBuilder interface in top of MutableList.
2 Views