The Defer Keyword in Swift

Playing around in Swift

Steven Curtis
4 min readMay 2, 2024


Photo by Romain V on Unsplash

The reason for this article is that defer is often useful, but seldom used (in my experience) where it could make things much easier for programmers using swift.

Difficulty: Beginner | Easy | Normal | Challenging

This article has been developed using Xcode 15.0, and Swift 5.9