https://kotlinlang.org logo
#getting-started
Title
# getting-started
m

Mihai Voicescu

10/26/2021, 12:05 PM
Is there anyway I can delegate to a getter 🙂 ? Something like
Copy code
class ReadLockFreeMutableMap<K, V>(
) : MutableMap<K, V> by mutableMap {
    private val mutableMap: MutableMap<K, V>
        get() {
            TODO()
        }
}
d

Dominaezzz

10/26/2021, 12:16 PM
Nope!
h

hfhbd

10/26/2021, 12:43 PM
Only if you move the getter to the constructor:
Copy code
class ReadLockFreeMutableMap<K, V>(
    private val mutableMap: MutableMap<K, V>
) : MutableMap<K, V> by mutableMap {
}
d

Dominaezzz

10/26/2021, 12:45 PM
(Not really a getter at that point 😛 )
😆 1
m

Mihai Voicescu

10/26/2021, 12:47 PM
Any particular reason this is not implemented? Seems rather useful...
4 Views