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.