Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun main(args: Array<String>) = runBlocking<Unit> {
- val squares = produceSquares(5)
- squares.consumeEach { println(it) }
- println("Done")
- }
- fun CoroutineScope.produceSquares(max: Int): ReceiveChannel<Int> = produce {
- for (x in 1..max) {
- send(x * x)
- }
- }
Add Comment
Please, Sign In to add comment