IRomanov
05/30/2018, 9:16 AMfun mapWithoutNullKeys(myMap: Map<String?, String>): Map<String, String> = myMap
.map { it.key to it.value }
.filterIsInstance<Pair<String, String>>()
.toMap()
because a lot of transformations and some overhead or
fun mapWithoutNullKeys(myMap: Map<String?, String>): Map<String, String> {
return myMap.filterKeys { it != null } as Map<String, String>
}
because of unchecked cast.
Maybe there is some method from stdlib for that task?