I’m confused about the behavior of `put` on Mutabl...
# stdlib
h
I’m confused about the behavior of
put
on MutableMaps. I have a simple extension function:
Copy code
internal fun MutableMap<String, JsonElement>.putAsJsonElement(key: String, value: String?) {
    value?.let { this.put(key, JsonPrimitive(it)) }
}
which does not appear to put the value in my map as I would expect. However! If I add a single print statement the map does get correctly updated:
Copy code
internal fun MutableMap<String, JsonElement>.putAsJsonElement(key: String, value: String?) {
    value?.let {
        this.put(key, JsonPrimitive(it))
        println(this)
    }
}
What the heck? Why does the second work when the first doesn’t?
c
are you really sure the first method isn’t working?
yes black 1
h
I've tried to reproduce it – it works fine: https://pl.kotl.in/mRbyW_Erj
c
lol chasing ghosts. @Harold Martin this doesn’t look to be a Kotlin issue, please review your environment, test setup etc.