plus
Creates a new view of this CoroutineScope, but with the specified context added to it.
This is a shorthand for CoroutineScope(thisScope.coroutineContext + context) and can be used as a combinator with existing constructors:
val myApplicationLifetimeScope = GlobalScope + CoroutineExceptionHandler { _, e ->
myLogger.error("Error in coroutine: $e")
}Content copied to clipboard
Pitfall: if context contains a Job, the new job will override the existing one in the scope. This means that in terms of structured concurrency, the new scope will be unrelated to the old one. Because of backward compatibility guarantees, plus does not check for this case, even though it is a source of bugs.