DEV Community

Discussion on: My first week of learning Swift.

Collapse
 
nunovieira profile image
Nuno Vieira • Edited

in 7) What you really should do to print the "name", is unwrapping the optional with Optional Binding (if-let) Example:

if let name = name {
       print(name)
}

With this approach, you don't need to verify first if it is nil and then force unwrap it. (Normally force unwrapping things in swift is a bad practice, unless is Outlets or if you don't have any other option for some kind of reason)

Collapse
 
s_awdesh profile image
Awdesh

Perfect. That's a great input.

I have updated the article now.