Re:Spf13 is leaving Google
by tptacek on Tuesday July 19, 2022 @02:29AM
(#32148209)
It is deeply idiomatic in the language.
[ Parent
| on HN ]
But only because there's no `contains` function!
Re:Spf13 is leaving Google
by ignoramous on Tuesday July 19, 2022 @03:40AM
(#32148610)
If perl has taught us anything... 3 ways to do something is worse than 1.
Re:Spf13 is leaving Google
by peoplefromibiza on Tuesday July 19, 2022 @03:43AM
(#32148635)
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.Agreed that `key in m` or `m.contains(key)` would be clearer, but checking the value rather than the presence is asking for trouble.