Go Time: Golang, Software Engineering cover image

The bits of Go we avoid (and why)

Go Time: Golang, Software Engineering

CHAPTER

Can Slices.clip Be Used to Override Existing Values?

There's a function in the experimental generic slices package, which has actually been approved to be added to go 121 next fall. It sets the capacity of the slice to whatever the current length of the slice is. And so that way, if anybody does append to it, they'll get a copy instead of rewriting the existing one. I feel like that's so much clearer. If you're reading some code and you see slices.clip, it's like, okay, that's what they're doing. They're just like making sure nobody overwrites the end of the slice. But yeah, it does look quite weird. Remove bear return. The issue number 2 1 2 9 1 proposal go

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