arrow-fx-coroutines / arrow.fx.coroutines.stream / lastOrNull
suspend fun <O>
Stream
<O>.lastOrNull(): O?
Runs all the effects of this Stream, and returns null
if the stream emitted no values
and returning the last value emitted if values were emitted.
import arrow.fx.coroutines.stream.*
//sampleStart
suspend fun main(): Unit =
Stream(1, 2, 3)
.lastOrNull()
.let(::println) // 3
//sampleEnd
This a terminal operator, meaning this functions suspend
s until the Stream finishes.
If any errors are raised while streaming, it’s thrown from this suspend
scope.
Do you like Arrow?
✖