How golang --- map to determine whether there is key

Determined way value, ok: = map [key], ok there is true

main Package 

Import "FMT" 

FUNC main () { 

	Demo: = Map [String] BOOL { 
		"A": to false, 
	} 

	// error, a presence, but returns to false 
	fmt.Println (Demo [ "A"]) 

	// The method of determining the correct 
	_, OK: Demo = [ "A"] 
	fmt.Println (OK) 
}

  

Guess you like

Origin www.cnblogs.com/saryli/p/11639682.html