commonMain.com.github.insanusmokrassar.TelegramBotAPI.utils.Map.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TelegramBotAPI-jvm Show documentation
Show all versions of TelegramBotAPI-jvm Show documentation
Library for Object-Oriented and type-safe work with Telegram Bot API
package com.github.insanusmokrassar.TelegramBotAPI.utils
fun mapOfNotNull(vararg pairs: Pair): Map {
return HashMap().apply {
pairs.forEach {
(key, value) ->
value ?.also {
put(key, it)
}
}
}
}
fun Map.mapNotNullValues(): Map = asSequence().mapNotNull {
it.value ?.let { value ->
it.key to value
}
}.toMap()