Back to Basics: Equatable

Episode #297 • Oct 7, 2024 • Subscriber-Only

In this series we go back to basics with a deep dive into the subject of Equatable types. Equatability is a deceptively simple topic. It is a surprisingly tricky protocol that has some very specific semantics that must be upheld baked into it, and there are many misconceptions on how one can or should conform types to this protocol.

Collection
Equatable and Hashable
Back to Basics: Equatable
Locked

Unlock This Episode

Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.

Sign in with GitHub

Introduction

Stephen

We’re starting a new style of episode here on Point-Free called “Back to basics.”

Most of the time on Point-Free we enjoy diving deep into a topic by devoting multiple episodes to setting up the problem, then solving the problem in a robust way, and then showing how all new fantastic benefits start to pop out when you put in the hard work. And along the way we have explored many advanced topics of the Swift programming language, such as concurrency, value type semantics, existentials, advanced generics, and a lot more.

But often those lessons are tarnished by the fact that they are embedded in a long series of episodes on some other topic, and so many of our viewers may miss out who don’t meticulously watch every single episode.

Brandon

And so our “Back to basics” episodes are going to focus on one very specific topic related to the Swift programming language, and try uncover everything there is to be known about that topic. And we are kicking things off with a seemingly simple topic, the Equatable and Hashable protocols. But it turns out this topic is not so simple after all. They are surprisingly tricky protocols and they have some very specific semantics baked into them that must be upheld, and unfortunately there are a lot of misconceptions in the Swift community on how one can conform types to this protocol. Especially when it comes to reference types.

Stephen

So, let’s take a moment to familiarize ourselves with the Equatable protocol, give a deep reading of the documentation for it, and see how things can go wrong if you play fast and loose with the semantics of the protocol.

Let’s dig in.

Equivalence relations


References

Downloads

Get started with our free plan

Our free plan includes 1 subscriber-only episode of your choice, access to 64 free episodes with transcripts and code samples, and weekly updates from our newsletter.

View plans and pricing