gobyexample/027-ok-guards/ok-guards.go
Mark McGranaghan 434392e67c index work
2012-09-23 14:54:59 -07:00

23 lines
298 B
Go

// ## OK Guards
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