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 variables created with optional binding in an if statement are available only within the if statement block.

Leave a Reply