The Defer Statement in Swift

Gabriel Theodoropoulos
3 min readNov 12, 2021
Photo by Towfiqu barbhuiya on Unsplash

There are a few small things in Swift that can make a developer’s life much easier, and the coding process more efficient. One of them is the defer statement, which usually leads to writing shorter and simpler code when used. Before getting to know how to use defer, it’s necessary initially to understand its purpose. So, let’s get started with that.

What defer is all about

--

--

Gabriel Theodoropoulos

An iOS & macOS app maker writing code in Swift. Author of countless programming tutorials. Content creator. https://serialcoder.dev