Skip to content

Commit

Permalink
fix: get rid of horizontal scrolling by splitting the comment and sho…
Browse files Browse the repository at this point in the history
…w more code mentioned (#4100)
  • Loading branch information
PetrakovichVictoria committed Apr 16, 2024
1 parent f8d1821 commit 515308d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions docs/topics/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ fun main() = runBlocking {
//sampleStart
val channel = Channel<Int>()
launch {
// this might be heavy CPU-consuming computation or async logic, we'll just send five squares
// this might be heavy CPU-consuming computation or async logic,
// we'll just send five squares
for (x in 1..5) channel.send(x * x)
}
// here we print five received integers:
Expand Down Expand Up @@ -103,12 +104,12 @@ and an extension function [consumeEach], that replaces a `for` loop on the consu
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*

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

fun main() = runBlocking {
//sampleStart
val squares = produceSquares()
squares.consumeEach { println(it) }
println("Done!")
Expand Down
3 changes: 2 additions & 1 deletion kotlinx-coroutines-core/jvm/test/guide/example-channel-01.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import kotlinx.coroutines.channels.*
fun main() = runBlocking {
val channel = Channel<Int>()
launch {
// this might be heavy CPU-consuming computation or async logic, we'll just send five squares
// this might be heavy CPU-consuming computation or async logic,
// we'll just send five squares
for (x in 1..5) channel.send(x * x)
}
// here we print five received integers:
Expand Down

0 comments on commit 515308d

Please sign in to comment.