What is a `suspend` function in Kotlin?

Tests your grasp of Kotlin's core concurrency primitive. A `suspend` function can pause and resume. It must be called from another suspend function or a coroutine builder.
This tests your understanding of Kotlin's non-blocking concurrency model. A great answer defines a `suspend` function as one that can be paused and resumed, states its two calling rules (from another suspend function or a coroutine builder), and explains the compiler uses Continuation-Passing Style (CPS). A common red flag is stating that `suspend` automatically runs code on a background thread. It only makes the function pausable; a `Dispatcher` controls the thread.
Read the original → kotlinlang.org
- #kotlin
- #coroutines
- #concurrency
- #android
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.