4 ms·
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, et
by tym0 10mo ago
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`.
- Joker_vD 10mo agoI could've sworn we got "sets" in the Go's standard library along with the "maps" module but... apparently not? Huh.
- kevindamm 10mo agoAlmost 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 https://github.com/golang/go/discussions/47331
- vips7L 10mo agoHonestly insane in 2025 to not have a generic Set.
- frou_dh 10mo agoe.g. https://pkg.go.dev/github.com/zyedidia/generic/mapset https://pkg.go.dev/github.com/zyedidia/generic/mapset