asSequence
fun <T> Array<out T>.asSequence(): Sequence<T>fun ShortArray.asSequence(): Sequence<Short>fun FloatArray.asSequence(): Sequence<Float>fun DoubleArray.asSequence(): Sequence<Double>fun BooleanArray.asSequence(): Sequence<Boolean>Creates a Sequence instance that wraps the original array returning its elements when being iterated.
import kotlin.test.*
fun main(args: Array<String>) {
//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.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val collection = listOf('a', 'b', 'c')
val sequence = collection.asSequence()
println(sequence.joinToString()) // a, b, c
//sampleEnd
}