Add samples for mapNotNull, find, getOrNull functions

This commit is contained in:
Elijah Verdoorn
2020-04-26 18:03:11 -07:00
committed by Abduqodiri Qurbonzoda
parent 62df2b3195
commit 41d5615608
10 changed files with 154 additions and 0 deletions
@@ -98,6 +98,8 @@ public inline fun <K, V, R> Map<out K, V>.map(transform: (Map.Entry<K, V>) -> R)
/**
* Returns a list containing only the non-null results of applying the given [transform] function
* to each entry in the original map.
*
* @sample samples.collections.Maps.Transformations.mapNotNull
*/
public inline fun <K, V, R : Any> Map<out K, V>.mapNotNull(transform: (Map.Entry<K, V>) -> R?): List<R> {
return mapNotNullTo(ArrayList<R>(), transform)