Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
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>) {
val map = emptyMap<String, Int>()
println("map.isEmpty() is ${map.isEmpty()}") // true

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

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.