always
Creates an Eval instance from a function deferring it's evaluation until .value()
is invoked recomputing each time .value()
is invoked.
Parameters
f
is a function or computation that will be called every time .value()
is invoked.
import arrow.eval.*
fun main() {
//sampleStart
val alwaysEvaled = Eval.always { "expensive computation" }
println(alwaysEvaled.value())
//sampleEnd
}
Content copied to clipboard
"expensive computation" is computed every time value()
is invoked.