Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumKotlinproperty delegation lazySingle-choice MCQ

Can `by lazy` be applied to a local variable inside a function, and what is the typical reason to do so?

fun process(items: List<Int>) { val summary by lazy { items.sum() } if (items.isNotEmpty()) println(summary) }