Receiving a single element

In order to read a single element from a producer, the function receive() can be used, as follows for example:

val producer = produce {
send(5)
send("a")
}

fun main(args: Array<String>) {
println(producer.receive())
println(producer.receive())
}

his code will first print the number five, and then it will print the letter a.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.93.0