How do you properly unwrap both normal and implicit optionals?
There seems to be confusion in this topic and I would just like to have a reference for all of the way
An optional type means that the variable might be nil.
Example:
var myString: Int? = 55
myString = nil
The question mark indicates it might have nil value.
But if you state like this:
var myString : Int = 55
myString = nil
It will show error.
Now to retrieve the value you need to unwrap it:
print(myString!)
But if you want to unwrap automatically:
var myString: Int! = 55
Then:
print(myString)
No need to unwrap. Hope it will help.