gobyexample/017-ok-guards.go
2012-09-20 22:09:22 -07:00

20 lines
292 B
Go

// Ok Guard
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)
}
}