Go Time: Golang, Software Engineering cover image

What's new in Go 1.20

Go Time: Golang, Software Engineering

CHAPTER

What's the Deal With Comparative Types in Go?

In the Go spec, there's this idea of comparable types and then types that are not comparable. A comparable type is like if you have two strings, you can say string X equals string Y or string X does not equal string Y. There are things that are not similar in Go such as slices being different areas in memory. You're just not allowed to compare slices to each other. That's the only legal comparison you can make. And so for interface types, this gets a little bit weird. If you want to say X equal to Y and X and Y are both some interface type, you can do that even if the concrete type underneath the interface is something that wouldn't normally be

00:00
Transcript
Play full episode

Remember Everything You Learn from Podcasts

Save insights instantly, chat with episodes, and build lasting knowledge - all powered by AI.
App store bannerPlay store banner