I wrote a simple code block to store fragments
with ids
in Map
. The value
and key
of map is initialized as non-nullable but when I want to get them as key
and value
, it gives nullable
type data. So, I don't understand why? Is there any other type of map that returns non-nullable
data in Kotlin
?
It is possible that there is no value for key [position], which will make it return null
:
abstract operator fun get(key: K): V?
Returns the value corresponding to the given key, or null if such a key is not present in the map.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With