concept compiler in category swift

appears as: The compiler, compiler, Compiler
Swift in Depth

This is an excerpt from Manning's book Swift in Depth.

Listing 2.17. Compiler notifies you of an error
error: switch must be exhaustive
    switch dateType {
    ^

add missing case: '.year(_)'
    switch dateType {

Use some caution when working with raw values, because once you read an enum’s raw values, you lose some help from the compiler.

For peace of mind, you can add an isEmpty check for extra runtime safety to be super-duper safe in critical places in your application—such as sending newsletters—but at least you now get some help from the compiler.

  • It’s safer to force unwrap optionals if you know better than the compiler.