• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3  */
4 
5 // This file was automatically generated from channels.md by Knit tool. Do not edit.
6 package kotlinx.coroutines.guide.exampleChannel03
7 
8 import kotlinx.coroutines.*
9 import kotlinx.coroutines.channels.*
10 
<lambda>null11 fun CoroutineScope.produceSquares(): ReceiveChannel<Int> = produce {
12     for (x in 1..5) send(x * x)
13 }
14 
<lambda>null15 fun main() = runBlocking {
16     val squares = produceSquares()
17     squares.consumeEach { println(it) }
18     println("Done!")
19 }
20