Every program should grapple with failure. A happy path is only a part of the story. There are many ways to handle errors. The essential toolkit showcases throwing and catching exceptions, passing results, leveraging optionals, aborting, and asserting.

Asserts

Assertions let you discover programming errors during development, but are ignored in production.

Asserts

Assertions need to be enabled during compilation.

They are still experimental for Native targets.

var theMeaningOfApp: Any = 42

// OK for JVM, experimental for Native targets.
// Assertions need to be enabled during compilation to do the checks, 
// otherwise no-op.
assert(theMeaningOfApp is String) // throw AssertionError

[--]