Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumKotlinFlow cold streamsSingle-choice MCQ

Why does this attempt to switch the emitting dispatcher throw an IllegalStateException at runtime?

import kotlinx.coroutines.* import kotlinx.coroutines.flow.* fun broken(): Flow<Int> = flow { withContext(Dispatchers.IO) { emit(1) } }