Updated on 2026-08-14
This commit is contained in:
parent
7a197ec6c9
commit
c662136303
26 changed files with 906 additions and 346 deletions
|
|
@ -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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue