asSequence
Creates a Sequence instance that wraps the original array returning its elements when being iterated.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = arrayOf('a', 'b', 'c')
val sequence = array.asSequence()
println(sequence.joinToString()) // a, b, c
//sampleEnd
}
Creates a Sequence instance that wraps the original collection returning its elements when being iterated.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val collection = listOf('a', 'b', 'c')
val sequence = collection.asSequence()
println(sequence.joinToString()) // a, b, c
//sampleEnd
}
Creates a Sequence instance that wraps the original map returning its entries when being iterated.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val map = mapOf(1 to "x", 2 to "y", -1 to "zz")
val sequence = map.asSequence()
println(sequence.joinToString()) // 1=x, 2=y, -1=zz
//sampleEnd
}