W3cubDocs

/Kotlin

emptyMap

fun <K, V> emptyMap(): Map<K, V>

Returns an empty read-only map of specified type.

The returned map is serializable (JVM).

import kotlin.test.*
import java.util.*

fun main(args: Array<String>) {
//sampleStart
val map = emptyMap<String, Int>()
println("map.isEmpty() is ${map.isEmpty()}") // true

val anotherMap = mapOf<String, Int>()
println("map == anotherMap is ${map == anotherMap}") // true
//sampleEnd
}

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/empty-map.html