Lets say `Foo` is a `Stream<Whatever>`, I wa...
# announcements
f
Lets say
Foo
is a
Stream<Whatever>
, I want to map and convert it to a Sequence, is there any difference at all between these?
Copy code
foo
.asSequence()
.map { it.doStuff() }
or
Copy code
foo
.map { it.doStuff() }
.asSequence()
r
The first does the
map
operation on the stream, the second does it on the sequence.
The end result should be the same, but the first uses Java APIs and the second uses Kotlin APIs.
f
Yeah, I’m thinking about performance
d
The performance would expectably be very similar. Do a test if you want.
f
Yeah I guess. I was mainly interested in knowing if there was some practice for this, so you don’t break laziness or utilize it on the best way or whatever but I guess
Sequence
and
Stream
should be pretty interchangable on that
d
When you invoke
asSequence()
, that's not even a terminal operation