consider the following code: ``` fun main(args: Ar...
# coroutines
v
consider the following code:
Copy code
fun main(args: Array<String>) = runBlocking {
    val ch = Channel<Unit>()

    launch(CommonPool) {
        select<Unit> {
            ch.onReceive {
                println("0")
                launch(CommonPool) {
                    println("1")
                    ch.onReceive {
                        println("2")
                        ch.onReceive { println("3") }
                    }
                }
            }
        }
    }
    repeat(10) { ch.send(Unit) }
}
output
Copy code
0
1
So all
onReceive
belong to the
select
and I think they should be prohibited in (some kinds of?) nested scopes. Does it make sense or I'm missing something?