Q:

create a map from list kotlin

val map = mapOf(1 to "x", 2 to "y", -1 to "zz")
0
fun main() {
    val numbers = listOf("one", "two", "three", "four")

    println(numbers.associateBy { it.first().toUpperCase() })
    println(numbers.associateBy(keySelector = { it.first().toUpperCase() }, valueTransform = { it.length }))
}
0

New to Communities?

Join the community