Thanks Roman - like I said I’m just playing with t...
# coroutines
k
Thanks Roman - like I said I’m just playing with this so I have no specific use case. The go example (from gobyexample.com) looks like this
Copy code
select {
    case msg := <-messages:
        fmt.Println("received message", msg)
    case sig := <-signals:
        fmt.Println("received signal", sig)
    default:
        fmt.Println("no activity")
    }
I think this lets me select from two channels but if there’s nothing in either then to execute the default. Is the way to do this in Kotlin to poll both channels, something like:
Copy code
var value1 = producer1().poll()
when (value1) {
    is String -> println(value1)
    else -> {
        var value2 = producer2().poll()
        when (value2) {
            is String -> println(value2)
            else -> println("default")
        }
    }
}
This doesn’t seem as elegant as go which is why I thought about
onTimeout(0)