fold
Transforms a KResult into a value of R.
import io.kresult.core.KResult
import io.kotest.matchers.shouldBe
import kotlin.test.fail
fun test() {
KResult.Success(1)
.fold(
{ fail("Cannot be left") },
{ it + 1 }
) shouldBe 2
}
Content copied to clipboard
Return
Parameters
ifFailure
transform the KResult.Failure type E to R.
ifSuccess
transform the KResult.Success type T to R.