Spec-Zone.ru › Kotlin 2

emptyList

kotlin-stdlib/kotlin.collections/emptyList

Версия Kotlin: 1.0

fun <T> emptyList(): List<T>

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

Примеры

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

fun main() { 
   //sampleStart 
               val list = listOf<String>()
            println("list.isEmpty() is ${list.isEmpty()}") // true

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

            // "Empty lists are equal"
println("list == other is ${list == other}") // true
            println(list) // []
            // list[0] // will fail 
   //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-list.html

Spec-Zone.ru

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