Can someone explain what exactly is the difference between these two?
When do you use one over the other?
Thanks in advance.
I think Roman Elizarov explain it quite in details, but to make it short:
You have this kind of hierarchy:
Assume that "Coroutine i" fails. What do you want to happen with its parent?
If you want for its parent to also fail, use coroutineScope
. That's what structured concurrency is all about.
But if you don't want it to fail, for example child was some kind of background task which can be started again, then use supervisorScope
.