The drop()
operator for Flow
skips the first N emitted items, where N is the
value that you pass to drop()
. So, here, we skip the first four items,
so all we print are the remaining six.
You can learn more about this in:
Tags:
xxxxxxxxxx
1
import kotlinx.coroutines.*
2
import kotlinx.coroutines.flow.*
3
4
fun main() {
5
GlobalScope.launch(Dispatchers.Main) {
6
flowOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
7
.drop(4)
8
.collect { println(it) }
9
}
10
}