Spec-Zone.ru › Kotlin 2

emptySet

kotlin-stdlib/kotlin.collections/emptySet

В Kotlin с версии: 1.0

fun <T> emptySet(): Set<T>

Возвращает пустое множество только для чтения. Возвращаемое множество сериализуемо (JVM).

Примеры

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //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
}

© 2010–2026 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/empty-set.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API