Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Using a bool instead of empty struct also means that there is more way to use it wrong: check the bool instead of if the key exist, set the bool incorrectly, etc...

I would argue using bool hurts readability more.

Even better write/use a simple library that calls things that are sets `Set`.



I could've sworn we got "sets" in the Go's standard library along with the "maps" module but... apparently not? Huh.


Almost made it into 1.18 but looks like it doesn't add enough value and has some open questions like what to use for a backing data type and what complexity promises to make.

https://github.com/golang/go/discussions/47331


Honestly insane in 2025 to not have a generic Set.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: