
The article explains why recursive enums need the indirect keyword. It covers the problem (value types need a known size at compile time, but recursive cases create infinite size), the solution (indirect stores the case via heap reference), case level versus enum level indirect, practical examples like expression trees and file systems, and trade offs including heap allocation and indirection cost.
The article explains what inout parameters are, how copy-in copy-out works under the hood, and when to use them versus return values. It covers basic examples (incrementing, swapping, mutating collections), important rules (using &, variables only, no conflicting access), common mistakes, and best practices.
Sagar has been building apps since 2015 and has worked with startups and companies on some truly exciting projects.
Over the years, he has focused on creating apps for iOS, watchOS, and iPadOS, using Swift and, more recently, SwiftUI. He has also worked with frameworks like React and React Native, which has helped him adapt to different kinds of projects. He loves keeping up with new tech and trends — always learning and improving.
Outside of work
Sagar is a passionate runner. He started running regularly in October 2023, and it quickly became something he looks forward to every week. These days, he runs around 30KM per week, and in 2024, he hit a big milestone by running over 1,000KM in total!
Follow his running journey on Instagram (@sagar.runs) or Strava, where he shares updates and photos.
Beyond code
When he's not coding or running, Sagar enjoys spending time with family and friends. He's a huge foodie — always exploring new dishes and flavors. And as a big cricket fan, he enjoys both watching games and playing whenever he gets the chance.