Inside Swift

At the end of each article, press the "Mark this article as read" button to have the site remember you've read it.

Introduction – please watch!

6:22

Introduction – please watch!

The Inside Swift series is designed to explore Swift's own source code, so you can better understand how it works and also pick up techniques you can apply to your own code.

StaticString

13:10

StaticString

Sometimes less is more, and Swift's StaticString is a great example of how adding restrictions actually adds usefulness.

Increasing clarity with function attributes

20:15

Increasing clarity with function attributes

Swift does a great job of throwing up warnings and compile errors when our code isn't quite right, but by giving it a little extra information we can help control those warnings more precisely.

How to make abstract classes in Swift

12:45

How to make abstract classes in Swift

Swift doesn't support abstract classes, but sometimes we really need them. Helpfully, we can find a solution of sorts right inside Swift's own source code…

Zipping sequences

9:51

Zipping sequences

Swift has a dedicated zip() function that creates zipped sequences. This is not only useful, but also a great safety improvement for some code, and the standard library code for it is delightfully simple.

Expressible by array literal

22:15

Expressible by array literal

Although Swift is a very strict language, it also sprinkles a great deal of syntactic sugar around to make our lives easier. Let's explore a part of that here: types that are expressible as array literals…

The power of preconditions

17:46

The power of preconditions

Sometimes the safest thing to do is crash your code. That might sound odd, but it's true, and in this article I'll show you exactly how Swift does it…

Typed throws

18:58

Typed throws

Typed throws were introduced in Swift 6 to let us handle errors more neatly, and a great way to explore them is with Swift's own source code.

allSatisfy()

11:01

allSatisfy()

I want to look at a bafflingly brilliant piece of the Swift standard library: the allSatisfy() method of sequences, which I think is quite literally perfect. Let's get into it!

Literal strings and string interpolation

16:46

Literal strings and string interpolation

Have you ever wondered how string interpolation works in Swift? It's another important feature of the standard library, and even gets extensive use in SwiftUI! Let's dig in…

Conditional conformances

15:49

Conditional conformances

What lets us compare two arrays to see if they are the same? How can Swift encode and decode any optional value as long as the type it wraps is also Codable? The answer is conditional conformances, and they are one of my favorite features of Swift!

Single-item collections

7:27

Single-item collections

Collections like arrays and sets are how we store lots of objects in a single place, but what if we wanted to store only one item? More importantly, why would we want to store only one item?

OptionSet

14:03

OptionSet

Option sets are a feature so small and clever that you barely know they exist, but Apple uses them extensively and you should too.