If you’re a Swift developer you already know the power of “if let” for checking nil values.

Let’s take it to the next level with “guard / else” statement:

The “guard let / else” not only checks for nil, but after the check the variable remains a non-optional, so you can use it safely until you exit the current function.


Let’s dive into an example:

Leave A Comment

Receive the latest news in your email
Table of content
Related articles