diff --git a/docs/topics/channels.md b/docs/topics/channels.md index 7f41eaec2b..7cf222c8a0 100644 --- a/docs/topics/channels.md +++ b/docs/topics/channels.md @@ -573,6 +573,7 @@ Now let's see how it works in practice: import kotlinx.coroutines.* import kotlinx.coroutines.channels.* +//sampleStart fun main() = runBlocking { val tickerChannel = ticker(delayMillis = 100, initialDelayMillis = 0) // create ticker channel var nextElement = withTimeoutOrNull(1) { tickerChannel.receive() } @@ -596,7 +597,9 @@ fun main() = runBlocking { 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). > diff --git a/docs/topics/exception-handling.md b/docs/topics/exception-handling.md index 5ee55437db..c3e6135dd0 100644 --- a/docs/topics/exception-handling.md +++ b/docs/topics/exception-handling.md @@ -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 @@ -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). >