Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
0 points
peoplefromibiza
3y ago
0 comments
Share
what `contains` what?
you could write this in Go
if m[key] { }
the comma ok idiom simply lets you distinguish a "zero" value from a missing value.
undefined | Better HN
0 comments
default
newest
oldest
ndr
3y ago
Agreed that `key in m` or `m.contains(key)` would be clearer, but checking the value rather than the presence is asking for trouble.
simiones
3y ago
`if m[key] { }` is only valid Go if m is a map from something to bool, so I don't know what you even mean.
j
/
k
navigate · click thread line to collapse