I have a mutable map in which I want a default value 0 for key not found
I tried the below code withDefault({somevalue})
but still returns null
val attributes = mutableMapOf<String, Int>().withDefault({0})
attributes["orange"]=345
println(attributes["orange"])
println(attributes["orang"])
The result I get is 345 null
instead of 345 0
What is it I am missing here?
withDefault is to be used with getValue and not with get resp. [...]:
See: withDefault