• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
<lambda>null2  * 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 flow.md by Knit tool. Do not edit.
6 package kotlinx.coroutines.guide.exampleFlow10
7 
8 import kotlinx.coroutines.*
9 import kotlinx.coroutines.flow.*
10 
11 fun numbers(): Flow<Int> = flow {
12     try {
13         emit(1)
14         emit(2)
15         println("This line will not execute")
16         emit(3)
17     } finally {
18         println("Finally in numbers")
19     }
20 }
21 
<lambda>null22 fun main() = runBlocking<Unit> {
23     numbers()
24         .take(2) // take only the first two
25         .collect { value -> println(value) }
26 }
27