Skip to content

Commit f32fe71

Browse files
fix: get rid of horizontal scrolling by splitting the comment and show more code mentioned
1 parent f8d1821 commit f32fe71

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/topics/channels.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ fun main() = runBlocking {
1919
//sampleStart
2020
val channel = Channel<Int>()
2121
launch {
22-
// this might be heavy CPU-consuming computation or async logic, we'll just send five squares
22+
// this might be heavy CPU-consuming computation or async logic,
23+
// we'll just send five squares
2324
for (x in 1..5) channel.send(x * x)
2425
}
2526
// here we print five received integers:
@@ -103,12 +104,12 @@ and an extension function [consumeEach], that replaces a `for` loop on the consu
103104
import kotlinx.coroutines.*
104105
import kotlinx.coroutines.channels.*
105106

107+
//sampleStart
106108
fun CoroutineScope.produceSquares(): ReceiveChannel<Int> = produce {
107109
for (x in 1..5) send(x * x)
108110
}
109111

110112
fun main() = runBlocking {
111-
//sampleStart
112113
val squares = produceSquares()
113114
squares.consumeEach { println(it) }
114115
println("Done!")

0 commit comments

Comments
 (0)