Use of ‘defer statement’ in Swift

Defer statement can be used to defer the execution of certain line/s of code in the program. Statements within the defer statement will be executed only when the current scope of code execution is exited.

Example code using defer statement.

Leave a Reply