emptySet

Common
JVM
JS
Native
1.0
fun <T> emptySet(): Set<T>

Returns an empty read-only set. The returned set is serializable (JVM).

import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val set = setOf<String>()
println("set.isEmpty() is ${set.isEmpty()}") // true

// another way to create an empty set,
// type parameter is inferred from the expected type
val other: Set<Int> = emptySet()

// Empty sets are equal

println("set == other is ${set == other}") // true
println(set) // []
//sampleEnd
}