In the above code snippet, how does Kotlin compiler know that collect
in line #10 is to be invoked on the instance of the flow
on which merge
is invoked?
Isn’t this
in line #10 referring to CoroutineScope
as hinted in line #9 by the compiler?
Code snippet for reference
fun <T> Flow<T>.merge(other: Flow<T>): Flow<T> = channelFlow {
launch {
collect { send(it) }
}
other.collect { send(it) }
}
2