doc / ch.tutteli.atrium.logic.utils / nullableKeyMap


inline fun <K, V : Any> nullableKeyMap(map: Map<out K, V>): Map<out K?, V> (source)

Turns a Map into a map with a nullable key type.

Intended to be used in conjunction with platform types such as Map<Int!, String!`>! or in other words, when you deal with Java and you want to turn a platform type into a nullable type.

Basically it is a replacement for cast but without introducing one explicitly (we only give an additional hint to the compiler that we expect a nullable type and not a non-nullable one). For instance, instead of writing getPersons() as Map<String?, Person> you can write nullableKeyMap(getPersons())