From Apples Swift programming guide:
- var possibleString: String? = "an optional string"
Optional is value is either contains a value or nil value to indicate the that the value is missing.
While using you have to use if and let together, as
var newString : String
if let possibleString = possibleString {
newString = possibleString
}
2.
var assumedString: String! = "an implicitly unwrapped optional string"
An implicitly unwrapped optional is similar to optional types but we can use it like a non optional value each time when it is accessed.
In this case you can use it directly as
var newString : String
newString = possibleString