mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-16 13:23:47 +00:00
19 lines
448 B
Kotlin
19 lines
448 B
Kotlin
|
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||
|
|
||
|
fun <K, V> mapOfNotNull(vararg pairs: Pair<K, V?>): Map<K, V> {
|
||
|
return HashMap<K, V>().apply {
|
||
|
pairs.forEach {
|
||
|
(key, value) ->
|
||
|
value ?.also {
|
||
|
put(key, it)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fun <K, V> Map<K, V?>.mapNotNullValues(): Map<K, V> = asSequence().mapNotNull {
|
||
|
it.value ?.let { value ->
|
||
|
it.key to value
|
||
|
}
|
||
|
}.toMap()
|