arrow-core-data / arrow.core / SequenceK / mapNotNull
fun <B> mapNotNull(f: (A) -> B?):
SequenceK
<B>
Returns a SequenceK containing the transformed values from the original SequenceK filtering out any null value.
Example:
import arrow.core.*
//sampleStart
val evenStrings = listOf(1, 2).asSequence().k().mapNotNull {
when (it % 2 == 0) {
true -> it.toString()
else -> null
}
}
//sampleEnd
fun main() {
println("evenStrings = $evenStrings")
}
Do you like Arrow?
✖