Kotlin / kotlin-koans

Kotlin workshop
MIT License
2.6k stars 1.41k forks source link

Lesson 4 Task 2 error (lazy/get) #139

Open dmenne opened 6 years ago

dmenne commented 6 years ago

When I run the "correct" lazy property example on Android Studio, I get an error for get: unresolved reference, none of the following candidates..."

Works ok online.

class LazyProperty(val initializer: () -> Int) {
    var value: Int? = null
    val lazy: Int
        get() {
            if (value == null) {
                value = initializer()
            }
            return value!!
        }
}