Updated on 2026-08-14

This commit is contained in:
Tangem 2026-04-06 12:26:33 +04:00
parent 7a197ec6c9
commit c662136303
26 changed files with 906 additions and 346 deletions

View file

@ -1,11 +1,10 @@
package com.tangem.utils.extensions
fun <K, V, R> Map<K, V>.mapNotNullValues(transform: (Map.Entry<K, V>) -> R?): Map<K, R> {
return this
.mapNotNull { entry ->
val newValue = transform(entry) ?: return@mapNotNull null
entry.key to newValue
}
.toMap()
inline fun <K, V, R> Map<K, V>.mapNotNullValues(transform: (Map.Entry<K, V>) -> R?): Map<K, R> {
val result = linkedMapOf<K, R>()
this.forEach { entry ->
val newValue = transform(entry) ?: return@forEach
result[entry.key] = newValue
}
return result
}