In Kotlin’s Coroutine channels doc in Prime numbers with pipeline section there is an example that is ambiguous.
fun CoroutineScope.numbersFrom(start: Int) = produce<Int> {
var x = start
while (true) send(x++) // infinite stream of integers from start
}
How produce function can assign to numbersFrom extension function ?
I didn’t see any example like this in the doc.
produce function returns ReceiveChannel interface . The code inside curly braces is the implementation of produce function last parameter which is a function type but where is the implementation of numbersFrom body and how this code works ?
this is the link of doc example:
https://kotlinlang.org/docs/reference/coroutines/channels.html#prime-numbers-with-pipeline