Is passing the `ctx` to the `launch` method redund...
# coroutines
n
Is passing the
ctx
to the
launch
method redundant in this scenario?
Copy code
val ctx = newSingleThreadContext("sample")
val scope = CoroutineScope(ctx)
scope.launch(ctx) { }
l
Yes it is. It will no-op because it's the same
v
Why does
launch
accepts an optional context then? Can't the API be minimized to always use the scopes?
l
The additional and optional
CoroutineContext
is folded with the context from the scope. That gives you structured concurrency, but you can still launch in another dispatcher, or add something to the scope's context.