Harold Martin
08/04/2023, 4:11 PMput
on MutableMaps. I have a simple extension function:
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:
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?Chris Lee
08/04/2023, 4:20 PMhho
08/04/2023, 5:23 PMChris Lee
08/04/2023, 5:24 PM