How to get better at writing solutions in Swift?
As you're reading this newsletter, it's likely you're interested, experienced or just getting started with Swift. You might be able to write a working application, SDK code, or even complex solutions using all kinds of Swift features.
I often get asked how I stay up to date with the latest features or how I'm able to combine and use several kinds of Swift features in one solution. I shared
an article on dependency injection combining features like generics, static subscripts, and property wrappers a few weeks back, an example of combining features.
This week's article has two goals: teaching you how to throw an error if an optional contains no value and taking you on the journey I took to find the best solution for my problem. I'm learning new techniques every week, too, just by solving a problem w/o just using the knowledge I have at hand.
Sure, you can write a solution with simple techniques like guards and if let statements, but wouldn't it be more fun to explore a little further and find more advanced solutions to the same problem? It's my way of getting better at writing solutions in Swift while at the same time learning more about the features that Swift offers. Writing an article to summarize my learnings is a great way to not forget about these learnings while at the same time teaching you how to do the same.
I challenge you this week to take that extra mile and see if you can rewrite a certain solution by exploring features in Swift you didn't know yet. I bet that the new keywords navigator on the SwiftLee homepage will help a lot!
Good luck, and enjoy this week's SwiftLee Weekly.