Implicitly-unwrapped optionals

We can define implicitly-unwrapped Optionals by appending an exclamation mark (!) to the end of the type. These types of Optionals will unwrap themselves.

The following example presents two ways to get a value from a dictionary. In the first example, the resulting value will be an optional so should be unwrapped. The second example will implicitly unwrap the value:

Like forcefully unwrapping, implicitly-unwrapped Optionals may cause runtime crashes in our applications, so we need to be cautious when we use them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset