Tag: optional binding
-
Learning Swift Series: Part 2 – Optionals
In this series we will learn about Optionals in Swift. Optionals in Swift Forced Unwrapping of Optional Optional binding Implicitly Unwrapped Optional
-
Optional binding in Swift
If and while statements can be used to check whether an optional has a value and if yes, then extract the value and make it available for temporary constants or variables. We can use both constants and variables with optional binding. We don’t have to use ! to extract the optional value in optional binding. Constants and […]
-
Implicitly Unwrapped OptionalĀ in Swift
If the optional variable(or constant) will always have a value but not nil then we can unwrap the optional during its declaration itself by using ! instead of ? after the type. This will avoid unnecessary checks and unwrapping of optional value each time it is accessed. We can still use implicitly unwrapped optional to […]