aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/utilities/associateWithNotNull.kt6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/src/main/kotlin/utilities/associateWithNotNull.kt b/core/src/main/kotlin/utilities/associateWithNotNull.kt
new file mode 100644
index 00000000..ea2e8c3c
--- /dev/null
+++ b/core/src/main/kotlin/utilities/associateWithNotNull.kt
@@ -0,0 +1,6 @@
+package org.jetbrains.dokka.utilities
+
+inline fun <K, V : Any> Iterable<K>.associateWithNotNull(valueSelector: (K) -> V?): Map<K, V> {
+ @Suppress("UNCHECKED_CAST")
+ return associateWith { valueSelector(it) }.filterValues { it != null } as Map<K, V>
+}