@@ -22,7 +22,7 @@ fun main(args: Array<String>) {
2222Run this code:
2323
2424```
25- Hello!
25+ Hello,
2626World!
2727```
2828
@@ -60,9 +60,9 @@ fun main(args: Array<String>) = runBlocking { // start main coroutine
6060The result is the same, but this code uses only non-blocking ` delay ` .
6161
6262` runBlocking { ... } ` works as an adaptor that is used here to start the top-level main coroutine.
63- The regular code outside of ` runBlocking ` _ blocks_ , until the coroutine inside ` runBlocking ` works .
63+ The regular code outside of ` runBlocking ` _ blocks_ , until the coroutine inside ` runBlocking ` is active .
6464
65- This is also how you write unit-test for suspending functions:
65+ This is also a way to write unit-tests for suspending functions:
6666
6767``` kotlin
6868class MyTest {
@@ -76,7 +76,7 @@ class MyTest {
7676## Waiting for a job
7777
7878Delaying for a time while a _ child_ coroutine is working is not a good approach. Let's explicitly
79- wait (in a non-blocking way) until other coroutine that we have launched is complete:
79+ wait (in a non-blocking way) until the other coroutine that we have launched is complete:
8080
8181``` kotlin
8282fun main (args : Array <String >) = runBlocking {
@@ -85,7 +85,7 @@ fun main(args: Array<String>) = runBlocking {
8585 println (" World!" )
8686 }
8787 println (" Hello," )
88- job.join() // wait until children coroutine completes
88+ job.join() // wait until child coroutine completes
8989}
9090```
9191
@@ -96,8 +96,8 @@ the child coroutine in any way. Much better.
9696
9797## Extract function refactoring
9898
99- Let's extract the block of code inside ` launch(Here} { ... } ` into a separate function. If you
100- perform "Extract function" refactoring, you'll get a new function with ` suspend ` modifier.
99+ Let's extract the block of code inside ` launch(Here} { ... } ` into a separate function. When you
100+ perform "Extract function" refactoring on this code you get a new function with ` suspend ` modifier.
101101That is your first _ suspending function_ . Suspending functions can be used inside coroutines
102102just like regular functions, but their additional feature is that they can, in turn,
103103use other suspending functions, like ` delay ` in this example, to _ suspend_ execution of a coroutine.
0 commit comments