Set?

Generics have been around for a while now, and although this has been brought up before, do ya'll think a built in set data type like golang-set (or something similar) will come to the stdlib? Do you think it should?

I think it would be a great convenience at little to no cost to the practicalities or philosophies of Go.

5 points · 2 comments · view on lemmy.world

2 Comments

Carpet_Monster@lemmy.world · 1 pts · 3y (1 reply)

probably not. Don't need it much. Using map gets you the same functionality

mrh@mander.xyz · 2 pts · 3y

I find hacking maps to be sets with map[T]bool or map[T]struct{} to be awkward for the most rudimentary use case, membership checking, and downright onerous for anything more "complicated."

I feel as though the datastructure "an unordered collection of things without duplicates, with constant time lookup" is so simple and useful, I don't see any reason to keep it out of the language.