spand
04/22/2021, 5:59 AMT?
. ie. here I invented the !!
type operator for it. Should be clear from the example here why it makes sense.
interface LoadingCache<K : Any, V> {
fun get(key: K): V // <-- If it can return null then it must be specified by type V
// If load returns null then entries are missing hence it doesnt make sense to have here : Map<K,V?>
fun <MV : V!!> getAll(keys: Iterable<K>): Map<K, MV> {
return keys.mapNotNull { k -> get(k)?.let { k to it } }.toMap()
}
}