News for hackers. Stuff that matters.
Re:PEP 584 – Add + and – operators to the built-in dict class by bpicolo on Wednesday March 06, 2019 @04:43AM (#19317595)
To be fair, this is because the language does not support a type safe set type. I would use one frequently if it did
Re:PEP 584 – Add + and – operators to the built-in dict class by majewsky on Wednesday March 06, 2019 @01:11PM (#19321092)
map[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 {