https://kotlinlang.org logo
#coroutines
Title
# coroutines
k

kevin.cianfarini

02/07/2020, 10:39 PM
does
Channel.offer
on a
RendezvousChannel
always return false? Or will it return true if a receiver is already waiting for the next value?
o

octylFractal

02/07/2020, 10:42 PM
Copy code
suspend fun main() {
    val channel = Channel<String>(Channel.RENDEZVOUS)
    coroutineScope {
        launch(start = CoroutineStart.UNDISPATCHED) {
            println(channel.receive())
        }
        println("Offer returns: " + channel.offer("Hello!"))
    }
}
=
Copy code
Offer returns: true
Hello!
k

kevin.cianfarini

02/07/2020, 10:43 PM
thanks!
2 Views