2 ms·
Fwiw lots of folks dislike m[K]struct{}, because while it’s efficient checking for presence is horrible: _, present = m[k] It looks weird and is not an ex
by masklinn 4y ago
Fwiw lots of folks dislike m[K]struct{}, because while it’s efficient checking for presence is horrible:
_, present = m[k]
It looks weird and is not an expressions. Obviously you could paper over this with a dedicated builtin function but that’s not great.
A common alternative is m[string]bool, memory density is worse but contains/add/remove are easier to read and more convenient.