Answers for "map kotlin list"

1

kotlin map list

val numbers = setOf(1, 2, 3)
println(numbers.map { it * 3 })  // [3, 6, 9]
Posted by: Guest on May-31-2022
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