https://kotlinlang.org logo
#stdlib
Title
# stdlib
s

spand

10/23/2020, 11:28 AM
Is either the implementation or the documentation wrong for
Map<K, V>.getOrElse
? on ie.
Copy code
mapOf("1" to null).getOrElse("1") { error("missing") }
Will throw an error yet
containsKey("1")
return
true
. The docs says: ... or the result of the [defaultValue] function if there was no entry for the given key. There is an internal
getOrElseNullable
that would fix it but I assume it was not chosen for a reason
3
2 Views