Files
gobyexample/examples/ok-guards/ok-guards.go
Mark McGranaghan 8daa226a48 lean into examples
2012-10-09 21:02:12 -07:00

21 lines
310 B
Go

package main
import "fmt"
func main() {
x := make(map[string]string)
x["here"] = "yes"
if name, ok := x["?"]; ok {
fmt.Println(name)
} else {
fmt.Println("miss")
}
if name, ok := x["here"]; ok {
fmt.Println(name)
}
}
// todo: note about use with errors