Add Sequence.orEmpty #KT-16552 Fixed
This commit is contained in:
committed by
Ilya Gorbunov
parent
2ce0bca34e
commit
c4b785de36
@@ -47,6 +47,14 @@ private object EmptySequence : Sequence<Nothing>, DropTakeSequence<Nothing> {
|
||||
override fun take(n: Int) = EmptySequence
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this sequence if it's not `null` and the empty sequence otherwise.
|
||||
* @sample samples.collections.Sequences.Usage.sequenceOrEmpty
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Sequence<T>?.orEmpty(): Sequence<T> = this ?: emptySequence()
|
||||
|
||||
/**
|
||||
* Returns a sequence of all elements from all sequences in this sequence.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user