Skip to content
RED SAGSkills
hard20 pts · first answer countskotlin-flowkotlin-coroutines

Collecting a cold Flow twice

What does this Kotlin program print, one value per line?

val numbers = flow {
  println("start")
  emit(1)
  emit(2)
}

fun main() = runBlocking {
  numbers.collect { println(it) }
  numbers.take(1).collect { println(it) }
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions