Having a Map<K, V>, and need to look up by key and pass the result to a SDK's api which takes only on-null value. like:
fun doSomeThing(value: V)
The look up could be as
val v = theMap[key]
but the v is nullable now, even if the key used here is guaranteed to exist and the v will be not null.
is there a way to make function not return nullable in case need to look up from a map?
fun returnNotNullable(key: K): V {
check(keyExist())
return theMap[key]!! // dont like the !! here
}
just dont want to use !! like doSomeThing(theMap[key]!!)