Typically, when we call a function, control passes from the call site to the function, and then the statements within the function are executed sequentially until either the end of the function or until a return statement, as shown in the following diagram:
Sometimes, it can be useful to execute some code after the function has returned, but before control has been returned to the call site. This is where Swift's defer statement can be useful: