map

inline fun <R> map(f: (success: T) -> R): KResult<E, R>

Maps (transforms) the success value T to a new value R

import io.kresult.core.KResult
import io.kotest.matchers.shouldBe

fun test() {
KResult.Success(2)
.map {
it * it
}
.getOrNull() shouldBe 4
}

Parameters

f

transform the KResult.Success type T to R.