Day 15 is a review of the last two weeks of material! #100DaysOfSwiftUI
I kept on going back to the individual pages to find the syntax I needed while working on the tests, so I’m happy to have it all on one page: www.hackingwithswift.com/articles/…
Day 14 is optionals, guards, nil coalescing, optional chaining, and optional try.
Guards are new to me but I like them:
func double(number: Int?) -> Int? {
guard let number = number else {
return nil
}
return number * 2
}
Two weeks in the books! #100DaysOfSwiftUI
My Series 10 has had really inconsistent battery life (it died on me 8 miles into a run last week 🙃) so I’m happy to see potential fixes in this watchOS update.

Prototypes, opaque return types, extensions, and protocol extensions don’t have equivalents in JavaScript (and my TypeScript isn’t good enough to compare Swift to TS), but these concepts were straightforward enough that I breezed through day 13. #100DaysOfSwiftUI
copies of the same class share their underlying data, meaning that changing one changes them all, whereas structs always have their own unique data, and changing a copy does not affect the others.
I found this explanation confusing until I took the test and realized the difference.
In JS, creating an object or class instance and assigning it to two different variables matches the “copy” semantics above (the variable is a reference to the object).
The “struct” behavior (by value) is how primitives work in JS (string, bool, etc.). Objects never work this way.
Day 12 over! #100DaysOfSwiftUI
Structs, mutating
on methods, computed properties, property observers, custom initializers… it’s a lot but it was pretty easy to get through.
I think the only “new” concept (coming from JavaScript) was marking methods as mutating
.
Day 10 done so 10% of the way there! #100DaysOfSwiftUI
Dropping the parenthesis when calling functions with a closure blows my mind:
team.filter { $0.hasPrefix("T") }
The equivalent in JS:
team.filter($0 => $0.startsWith("T"))
Woo! The checkpoint test actually didn’t take me very long to complete.
Day 9 in the books! #100DaysOfSwiftUI
Really interesting that Swift has do
, but it’s not what you think!
do {
try throwingFunction1()
nonThrowingFunction1()
} catch {
print("Handle errors here")
}
In JS, that do
would be try
and no “try” is required before a throwing function.
Day 8 in the books! #100DaysOfSwiftUI
Awesome to me that this is valid:
func record(age: Int) { }
func record(year: Int) { }
Naming internal and external parameters separately is interesting too:
func square(of num: Int) -> Int {
return num * num
}
let result = square(of: 4)
Day 7 in the books! #100DaysOfSwiftUI
Day 6 is all about for
and while
loops.
I’ll be excited to learn the .map
and .filter
equivalents. I rarely use for
loops in JS and have only used while
a couple times in my career. 🫢
I wasn’t expecting to do FizzBuzz for the checkpoint test. There’s a first time for everything! #100DaysOfSwiftUI
My comment about no ===
in Swift was incorrect, thanks Matt!
I should know that a beginner course isn’t going to immediately explain referential equality, that won’t make sense yet.
No ===
in Swift (just ==
) is nice!
Enums being comparable is pretty cool too.
And switch
statements… is this the day I confess that I tend not to use them in JavaScript? Swift’s fallthrough
syntax seems much safer than JS needing a break
for each case
.
Day 5 done! #100DaysOfSwiftUI
This is really interesting:
let name: String
// …
name = "Chasen"
// Allowed once
In JavaScript, the “equivalent” (using const
) requires an initial value and doesn’t let you reassign it later. I like that Swift allows it be undefined and assigned just once.
Day 4 done! #100DaysOfSwiftUI
Coming from JS, there are some small differences in array and dictionary syntax. This really stood out to me (as nice and explicit):
let olympics = [
2016: "Rio de Janeiro",
2021: "Tokyo",
2024: "Paris"
]
print(olympics[2020, default: "Unknown"])
Day 3 in the books! #100DaysOfSwiftUI
This has a bug… can you spot it?
let temperature = 29
let converted = (temperature * 9 / 5) + 32
print("Celsius: \(temperature)")
print("Fahrenheit: \(converted)")
I thought the compiler might warn when losing precision like this, but I guess not!
Day 2 in the books! #100DaysOfSwiftUI
The Verge’s article on the iPhone 16 Pro made me realize that the “rich contrast” photographic style is where it’s at on my 15 Pro. www.theverge.com/24247538/…
It feels like some apps (like Passwords) get a lot of love and attention at Apple, while others languish. I wonder if the difference is in management, developer care, director priorities, or something else. hachyderm.io/@rmondell…
I’m going to compare Swift to JavaScript a lot as I get up to speed.
Seems like Swift’s var == let (in JS) and let == const. I’m sure that won’t trip me up…
Interesting that 1_00__00___00____00
is valid in Swift (JS only allows one separator per digit, not multiple).