Skip to content

Commit

Permalink
Add missing playground runnable comments (Kotlin#3258)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchong committed May 17, 2022
1 parent d3a9c9d commit b8c9aae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/topics/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ Now let's see how it works in practice:
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*

//sampleStart
fun main() = runBlocking<Unit> {
val tickerChannel = ticker(delayMillis = 100, initialDelayMillis = 0) // create ticker channel
var nextElement = withTimeoutOrNull(1) { tickerChannel.receive() }
Expand All @@ -596,7 +597,9 @@ fun main() = runBlocking<Unit> {

tickerChannel.cancel() // indicate that no more elements are needed
}
//sampleEnd
```
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}

> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-channel-10.kt).
>
Expand Down
3 changes: 3 additions & 0 deletions docs/topics/exception-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ It can be demonstrated by a simple example that creates root coroutines using th
```kotlin
import kotlinx.coroutines.*

//sampleStart
@OptIn(DelicateCoroutinesApi::class)
fun main() = runBlocking {
val job = GlobalScope.launch { // root coroutine with launch
Expand All @@ -47,7 +48,9 @@ fun main() = runBlocking {
println("Caught ArithmeticException")
}
}
//sampleEnd
```
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}

> You can get the full code [here](../../kotlinx-coroutines-core/jvm/test/guide/example-exceptions-01.kt).
>
Expand Down

0 comments on commit b8c9aae

Please sign in to comment.