https://kotlinlang.org logo
#announcements
Title
# announcements
b

bbaldino

07/12/2019, 8:57 PM
is there a way to expose a
MutableMap
externally as a
Map
without using a "wrapper" member? i.e.
Copy code
private val _data = mutableMapOf<Int, String>()
val data: Map<Int, String>
    get() = _data
j

josephivie

07/12/2019, 8:59 PM
If there is one, I haven't found it.
r

Ruckus

07/12/2019, 9:02 PM
No, backing properties are how it is supposed to be done: https://kotlinlang.org/docs/reference/properties.html#backing-properties
k

karelpeeters

07/12/2019, 9:02 PM
This is a commonly requested feature: https://youtrack.jetbrains.com/issue/KT-14663
b

bbaldino

07/12/2019, 9:03 PM
gotcha, thanks @Ruckus. and thanks for the link @karelpeeters i'll be sure to vote
k

karelpeeters

07/12/2019, 9:04 PM
@Ruckus Are you sure that's about the same thing?
r

Ruckus

07/12/2019, 9:04 PM
Yes...?
k

karelpeeters

07/12/2019, 9:05 PM
Yeah NVM I got some terms mangled up my bad.
r

Ruckus

07/12/2019, 9:05 PM
Ah, okay. I was worried I may have misread the question, despite the fact it's almost exactly the example in the docs 🙂
5 Views