I’m a bit confused with dictionaries in kotlin: ``...
# announcements
e
I’m a bit confused with dictionaries in kotlin:
Copy code
val map = mutableMapOf(...)
map[someKey] += 1  // error: operator += is not allowed on a nullable receiver :(
but my algrithm assumes that
someKey
is 100% presented in my map. Ok, I’ll try
!!
operator (this is one I need in my situation, right?)
map[someKey]!! += 1  // error: variable expected
map[someKey] = map[someKey]!! + 1
It works, but seems a bit verbose. And I know, that verbosity isn’t a kotlin way. Guys, need your help!