Skip to content

Glossary: Kotlin Beyond the Basics

withTimeout

Also written: withTimeoutOrNull, TimeoutCancellationException

Cancels a block that runs too long. `withTimeout` throws `TimeoutCancellationException`, while `withTimeoutOrNull` returns `null` so `?:` can supply a fallback.

Where the book teaches it

Related terms

cancellationElvis operator