From 3f95b7e031199a8ef499f06fd5c12a0f78d583e8 Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Fri, 25 Nov 2022 09:37:37 +0000 Subject: [PATCH] Clarify Map.getOrElse and MutableMap.getOrPut documentation #KT-21392 --- libraries/stdlib/src/kotlin/collections/Maps.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index 621f1735fc7..483060040c6 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -317,7 +317,8 @@ public inline operator fun Map.Entry.component2(): V = value public inline fun Map.Entry.toPair(): Pair = Pair(key, value) /** - * Returns the value for the given key, or the result of the [defaultValue] function if there was no entry for the given key. + * Returns the value for the given [key] if the value is present and not `null`. + * Otherwise, returns the result of the [defaultValue] function. * * @sample samples.collections.Maps.Usage.getOrElse */ @@ -348,8 +349,9 @@ internal inline fun Map.getOrElseNullable(key: K, defaultValue: () public fun Map.getValue(key: K): V = getOrImplicitDefault(key) /** - * Returns the value for the given key. If the key is not found in the map, calls the [defaultValue] function, - * puts its result into the map under the given key and returns it. + * Returns the value for the given [key] if the value is present and not `null`. + * Otherwise, calls the [defaultValue] function, + * puts its result into the map under the given key and returns the call result. * * Note that the operation is not guaranteed to be atomic if the map is being modified concurrently. *