Just to clarify the basics for myself, please corr...
# coroutines
v
Just to clarify the basics for myself, please correct me if I am wrong.
Copy code
val hotStream: ReceiveChannel<Int> = produce<Int> {
        var i = 0
        while (true) {
            i += 1
            println("hot-create item #$i")
            send(i)
        }
    }

    // Usage:
    val next = hotStream.receive()
Do I understand that correctly that
hotStream
in this snippet is a hot stream because it produces the elements regardless if we consume them or not, and
coldStream
below is a cold stream because it calculates the elements only after they are requested?
Copy code
val coldStream: ReceiveChannel<Deferred<Int>> = produce<Deferred<Int>> {
        var i = 0
        while (true) {
            val item = async(start = CoroutineStart.LAZY) {
                i += 1
                println("cold-create item #$i")
                i
            }

            send(item)
        }
    }

    // Usage:
    val next = coldStream.receive().await()
➕ 2