🎉 End-of-year Sale! Save 25% when you subscribe today.

Back to Basics: Advanced Hashable

Episode #300 • Oct 28, 2024 • Subscriber-Only

We zoom out a bit to get a greater appreciation for how Equatable and Hashable are used throughout the greater language and ecosystem, including actors, standard library types, SwiftUI, and more.

Previous episode
Back to Basics: Advanced Hashable
Next episode
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

So this proves that Swift Data has chosen to use referential identity for the Equatable and Hashable conformance of models, and we think this is the clearest sign that referential equality is typically the correct choice for classes. Even Swift Data models do not use structural equality, and they are classes that primarily represent simple data values held in some external store. So, if they can’t use structural equality, what hope do we have for other classes?

Brandon

There’s another situation where referential equality is the only way to make a reference Equatable, but it has to do with actors instead of classes. If you didn’t know, actors are reference types, but its stored properties are all protected by an isolation domain that requires you to await to access and mutate the properties if you are in a different isolation domain.

Let’s take a look.

Actors


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