LEARN

Swift tutorials

Practical Swift notes and examples, with the original Swift Owls URLs preserved.

When to use Swift Result Type vs Throws (and why it matters)

After explaining error handling using do-try-catch, I thought it would be irresponsible not to share my daily notes on the swift Result type . It's very simple to return result from a function and handle errors especially if you want to handle both cases, success & failure. Throws is great for immed

Read →

Swift Guard vs If: Why the "Bouncer" Beats the "Pyramid"

Lets piggyback off of the previous blog post where I showed you why private(set) was needed to protect your variables. You can read that post here : Using private(set) and why it's important . Here is the code that we're going to be referencing from that tutorial. struct BankAccount { var owner:Stri

Read →

Using private(set) and why it's important

Why even use private(set) when you can just declare the variable struct BankAccount { var owner:String var balance:Double } Imagine you're creating an app for a bank and every owner has a balance. Naturally, you may define a struct above with the variable balance and move on. Now the balance can be

Read →

Swift Hello World!

Learn how to write your first “Hello, World!” program in Swift using Playgrounds and SwiftUI. Simple examples, clear steps, and translations in 100 languages.

Read →