3 ms·
To be fair, this is because the language does not support a type safe set type. I would use one frequently if it did
by bpicolo 8y ago
To be fair, this is because the language does not support a type safe set type. I would use one frequently if it did
- majewsky 8y agomap[T]struct{} is a type-safe set type. It's just not an ergonomic one. FWIW, I'm usually using map[T]bool and only ever inserting `true` values. It uses a bit more space, but membership checks read like if set[key] { instead of if _, ok := set[key]; ok {