value

abstract val value: T(source)

Gets the lazily initialized value of the current Lazy instance. Once the value was initialized it must not change during the rest of lifetime of this Lazy instance.

Since Kotlin

1.0

Samples

import samples.assertPrints
import kotlin.concurrent.thread

fun main() { 
   //sampleStart 
   val answer: Lazy<Int> = lazy {
    println("Computing the answer to the Ultimate Question of Life, the Universe, and Everything")
    42
}

println("What is the answer?")
println(answer) // Lazy value not initialized yet.
println("Oh, now compute it please")
// Will print 'Computing...' and then 42
println(answer.value) // 42
println("Come again?")
// Will print 42
println(answer.value) // 42 
   //sampleEnd
}