We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3feef05 commit 75f634cCopy full SHA for 75f634c
core/kotlinx-coroutines-core/test/guide/example-channel-04.kt
@@ -18,14 +18,11 @@ fun main() = runBlocking {
18
//sampleEnd
19
}
20
21
-fun CoroutineScope.produceSquares(): ReceiveChannel<Int> = produce {
22
- for (x in 1..5) send(x * x)
23
-}
24
-
25
fun CoroutineScope.produceNumbers() = produce<Int> {
26
var x = 1
27
while (true) send(x++) // infinite stream of integers starting from 1
28
+
29
fun CoroutineScope.square(numbers: ReceiveChannel<Int>): ReceiveChannel<Int> = produce {
30
for (x in numbers) send(x * x)
31
0 commit comments