Y
Hacker News
new
|
ask
|
show
|
jobs
by
IshKebab
1425 days ago
But only because there's no `contains` function!
2 comments
ignoramous
1425 days ago
If perl has taught us anything... 3 ways to do something is worse than 1.
link
peoplefromibiza
1425 days ago
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.
link
ndr
1425 days 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.
link
simiones
1425 days 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.
link