<https://android.googlesource.com/platform/framewo...
# coroutines
p
s
Not sure…. because
CoroutineScope.cancel()
does just that…. maybe someone didn’t realize this extension method existed 🙂
s
I’m not sure how
closeWithRuntimeException
explains this..
p
It's called by
clear
. They have a map where they put all sorts of stuff inside and if it's cancellable they cancel it. That's why they made a custom scope that implements cancellable.
1
s
Ah… it’s not about calling
this.cancel()
vs
coroutineContext.cancel()
. Your question is about why calling it through a
Closable
interface…
p
I actually had 2 questions but only asked one 😄 So back to my original question: Is that completely equivalent? (cancelling the context vs cancelling the scope)
s
Yup. It looks like it. Just do ‘go to definition’ in your IDE of both extension functions and see how they’re implemented; basically the same.