News for hackers. Stuff that matters.
Re:Spf13 is leaving Google by IshKebab on Tuesday July 19, 2022 @02:33AM (#32148231)
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.
Re:Spf13 is leaving Google by ndr on Tuesday July 19, 2022 @05:10AM (#32149214)
Agreed that `key in m` or `m.contains(key)` would be clearer, but checking the value rather than the presence is asking for trouble.
Re:Spf13 is leaving Google by simiones on Tuesday July 19, 2022 @05:19AM (#32149273)
`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.