Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
IshKebab
on July 19, 2022
|
parent
|
context
|
favorite
| on:
Spf13 is leaving Google
But only because there's no `contains` function!
ignoramous
on July 19, 2022
|
next
[–]
If perl has taught us anything... 3 ways to do something is worse than 1.
peoplefromibiza
on July 19, 2022
|
prev
[–]
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.
ndr
on July 19, 2022
|
parent
|
next
[–]
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
on July 19, 2022
|
parent
|
prev
[–]
`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.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: