This is not the case in the IF statement of the SWIFT syntax:
1 " Swift " 2 if let name = optionname {3 print ("OK") 4 }
However, the following can occur:
" Swift " if let name = optionname { print ("OK")}
Let name = Optionname
When Optionname is an optional type, the above line of code syntax is called, optional binding
Explain:
The optional binding (optional binding) is used to determine whether an optional type contains a value, and if it is included, assigns the value to a temporary constant or variable. Optional bindings can be used in the IF and while statements, which can be used not only to determine whether there are values in an optional type, but also to assign values from an optional type to a constant or variable. ”
So. The first is to determine whether there is a value in Optionname, if so, assign the value to name, and then go to {}, otherwise skip large {}
If let name = Optionname {} In Swift explanation