What will be result of the following code execution?

Technology CommunityCategory: KotlinWhat will be result of the following code execution?
VietMX Staff asked 3 years ago
Problem

What will be the output?

val aVar by lazy {
    println("I am computing this value")
    "Hola"
}
fun main(args: Array<String>) {
    println(aVar)
    println(aVar)
}

For lazy the first time you access the Lazy property, the initialisation (lazy() function invocation) takes place. The second time, this value is remembered and returned:

I am computing this value
Hola
Hola