I have a Java function that has a Map<String, String
and needs to pass it to a Kotlin function for adding values to the map.
The problem is that if I have:
fun updateMap(map: Map<String, String>)
It seems that the map
is immutable and I can't do: map[KEY] = VALUE
as I get compilation error.
It would work if I did: fun updateMap(map: HashMap<String, String>)
but in that case I can't pass the original map
from the Java code without some casting which I would like to avoid if possible.
What is the solution for this?