filterOption
Filters out all elements that are None, and unwraps the remaining elements Some values.
import arrow.core.None
import arrow.core.Some
import arrow.core.filterOption
import io.kotest.matchers.shouldBe
fun test() {
generateSequence(0) { it + 1 }
.map { if (it % 2 == 0) Some(it) else None }
.filterOption()
.take(5)
.toList() shouldBe listOf(0, 2, 4, 6, 8)
}
Content copied to clipboard