create set from map kotlin code example
Example 1: convert string to set in kotlin
var stringSet = string.toSet() //Where 'string' is the string to converted
Example 2: 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 }))
}
Example 3: make map kotlin
val map = mapOf(1 to "x", 2 to "y", -1 to "zz")