Kotlin 2 · Classes and types

Compute a value on first use

lazy runs its block once, the first time the property is read.

val config by lazy { loadConfig() }

Official Kotlin 2 documentation

More classes and types commands

All classes and types commands · Kotlin 2 cheatsheet

Was this page helpful?