Skip to content

Commit 7c864d8

Browse files
committed
Fixed typos and improve code based on @orangy feedback
1 parent 731f0ad commit 7c864d8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

coroutines-guide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ Exception in thread "main" java.util.concurrent.CancellationException: Timed out
533533
<!--- TEST STARTS_WITH -->
534534

535535
We have not seen the [CancellationException] stack trace printed on the console before. That is because
536-
inside a cancelled coroutine `CancellationException` is a considered a normal reason for coroutine completion.
536+
inside a cancelled coroutine `CancellationException` is considered to be a normal reason for coroutine completion.
537537
However, in this example we have used `withTimeout` right inside the `main` function.
538538

539539
Because cancellation is just an exception, all the resources will be closed in a usual way.
@@ -806,7 +806,7 @@ Produces the output:
806806

807807
<!--- TEST LINES_START -->
808808

809-
So, the coroutine the had inherited `context` of `runBlocking {...}` continues to execute in the `main` thread,
809+
So, the coroutine that had inherited `context` of `runBlocking {...}` continues to execute in the `main` thread,
810810
while the unconfined one had resumed in the scheduler thread that [delay] function is using.
811811

812812
### Debugging coroutines and threads
@@ -1905,7 +1905,7 @@ fun main(args: Array<String>) = runBlocking<Unit> {
19051905
}
19061906
}
19071907
println(result)
1908-
val countActive = list.sumBy { deferred -> if (deferred.isActive) 1 else 0 }
1908+
val countActive = list.count { it.isActive }
19091909
println("$countActive coroutines are still active")
19101910
}
19111911
```

kotlinx-coroutines-core/src/test/kotlin/guide/example-select-04.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ fun main(args: Array<String>) = runBlocking<Unit> {
4242
}
4343
}
4444
println(result)
45-
val countActive = list.sumBy { deferred -> if (deferred.isActive) 1 else 0 }
45+
val countActive = list.count { it.isActive }
4646
println("$countActive coroutines are still active")
4747
}

0 commit comments

Comments
 (0)