is there a way to expose a `MutableMap` externally...
# announcements
b
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
If there is one, I haven't found it.
r
No, backing properties are how it is supposed to be done: https://kotlinlang.org/docs/reference/properties.html#backing-properties
k
This is a commonly requested feature: https://youtrack.jetbrains.com/issue/KT-14663
b
gotcha, thanks @Ruckus. and thanks for the link @karelpeeters i'll be sure to vote
k
@Ruckus Are you sure that's about the same thing?
r
Yes...?
k
Yeah NVM I got some terms mangled up my bad.
r
Ah, okay. I was worried I may have misread the question, despite the fact it's almost exactly the example in the docs 🙂