Every coroutine has an associated coroutine context, which is used to influence how a coroutine is handled at runtime. This context is an immutable set of elements where each element has a key and a value. You can think of the context as similar to a map, with each element in the context being a key-value entry in the map.
Since a context is immutable, adding or removing elements to a context results in a new context. To add new elements, the plus operator (+) is supported, for example:
coroutineContext + CoroutineName("my coroutine")
The context is used by various aspects of the coroutine library. A simple example is setting the name of the coroutine as shown in the last example. More advanced usages include controlling which thread or thread pool a coroutine should be dispatched on, or how a coroutine should handle uncaught exceptions.
Closely related...