A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-129.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6m:=map[string]int{"zero":0}
7ifv,ok:=m["zero"];ok{
8fmt.Println("present",v)
9}
10}
Maps
Answer & explanation
Console output
present 0
Why
The comma-ok form lets the if test presence (ok) independently of the value. "zero" is present with value 0, so ok is true and the branch executes, printing "present 0". Testing the value alone would wrongly treat a stored 0 as missing.