или Пусто
С версии Kotlin: 1.3
inline fun <T> Sequence<T>?.orEmpty(): Sequence<T>
Возвращает эту последовательность, если она не null, и пустую последовательность в противном случае.
Примеры
import kotlin.test.*
fun main() {
//sampleStart
val nullSequence: Sequence<Int>? = null
println(nullSequence.orEmpty().toList()) // []
val sequence: Sequence<Int>? = sequenceOf(1, 2, 3)
println(sequence.orEmpty().toList()) // [1, 2, 3]
//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.sequences/or-empty.html