Add a custom getter to make the val lazy really lazy. It should be initialized by invoking initializer() during the first access.
You can add any additional properties as you need.
Do not use delegated properties!
The answer code is
Copy code
class LazyProperty(val initializer: () -> Int) {
var value: Int? = null
val lazy: Int
get() {
if (value == null) {
value = initializer()
}
return value!!
}
}
I tried the below and it also pass
Copy code
class LazyProperty(val initializer: () -> Int) {
val lazy by lazy {
initializer()
}
}
I'm not sure the intent of this tutorial introducing