arrow-core-data / arrow.core / Eval / later
@JvmStatic inline fun <A> later(crossinline f: () -> A): Later<A>
Creates an Eval instance from a function deferring it’s evaluation until .value()
is invoked memoizing the computed value.
f
-
is a function or computation that will be called only once when .value()
is invoked for the first time.
import arrow.core.*
fun main() {
//sampleStart
val lazyEvaled = Eval.later { "expensive computation" }
println(lazyEvaled.value())
//sampleEnd
}
“expensive computation” is only computed once since the results are memoized and multiple calls to value()
will just return the cached value.
Do you like Arrow?
✖