in following lines of code, anothervariable
constant implicitly inherits right side string
type instead of string?
var variable: string? = "hello" if let anothervariable = variable { // unwrapping // "anothervariable" constant has string type , value "hello" }
yes, optional unwrapping. when use if let
on optional value:
- you enter body of condition if optional value non-nil, and
- the value assign of non-optional type, can use without unwrapping within scope of body of conditional.