Of course this is all guesswork based on similar stuff i've seen elsewhere, so i might be off, but i think despite not knowing the language it still looks readable if you know any other mainstream language (and exercise some guesswork/imagination :-P).
I can say the same about Fennel, List or Haskell.
The first example is the way to go in Go. It's idiomatic, not a hack. And it works the same way for many things (for example checking if a channel's closed)
you could write this in Go
if m[key] { }
the comma ok idiom simply lets you distinguish a "zero" value from a missing value.Hopefully that helps explain the matter...
GP wasn't discussing the language in general, just a small feature that depends on an idiomatic pattern used in many other places, saying "it looks gibberish." Of course it does, because it isn't idiomatic for you.
It's less about length of code and more about cognitive load; this is why functional programming constructs are frowned upon in Go code, because the cognitive load per line of code is much higher.
Also `if m.contains(key) { }` is even more obvious IMO.
Why though? it doesn't even save you much space compared to standard use:
if _, ok := m[key]; ok { }
vs
if contains(m, key) { }
I'm not strictly against it, but it can open pandora's box of all kinds of weird sugar flavors.