Answers for "convert list to map using map kotlin"

1

create a map from list kotlin

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 }))
}
Posted by: Guest on September-25-2020

Browse Popular Code Answers by Language