orEmpty

inline fun <T> Sequence<T>?.orEmpty(): Sequence<T>(source)

Returns this sequence if it's not null and the empty sequence otherwise.

Since Kotlin

1.3

Samples

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
}