This is done to avoid silent errors. Someone could have written observeOn operator as withContext(ctx) { collect { emit(it) } } hoping that this operator would change the “downstream” context. If that were to be silently “corrected” it will be hard to catch this misunderstanding in the test. We don’t just throw an exception. We also give clues as to what operators to look at in its message.

Written by

Project Lead for the Kotlin Programming Language @JetBrains

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store