Defer in Swift explained with Code Examples

Although the defer keyword was already introduced in Swift 2.0, it s still quite uncommon to use it in projects. Its usage can be hard to understand, but using it can improve your code a lot in some places. The most common use case seen around is opening and closing a context within a scope. Starting