mapOf

fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V>(source)

Returns an immutable map, mapping only the specified key to the specified value.

The returned map is serializable.

Since Kotlin

1.0

Samples



import kotlin.test.*


import java.util.*
fun main() { 
   //sampleStart 
   val map = mapOf(1 to "x", 2 to "y", -1 to "zz")
println(map) // {1=x, 2=y, -1=zz} 
   //sampleEnd
}
fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V>(source)

Returns an immutable map, mapping only the specified key to the specified value.

Since Kotlin

1.1