sequenceOf
Creates a sequence that returns the specified values.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val sequence = sequenceOf("first", "second", "last")
sequence.forEach(::println)
//sampleEnd
}
Creates a Sequence that contains a single given element.
Since Kotlin
2.2Return
a sequence containing only the specified element.
Parameters
element
the single element to be contained in the resulting sequence.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val sequence = sequenceOf("single")
println(sequence.toList()) // [single]
//sampleEnd
}
Creates an empty Sequence.
Since Kotlin
2.2Return
an empty sequence.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val sequence = sequenceOf<String>()
println(sequence.toList()) // []
//sampleEnd
}