Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 288 Bytes

how-to-check-if-a-map-contains-a-key-in-go.md

File metadata and controls

19 lines (14 loc) · 288 Bytes

如何判断map中是否存在某个key

stackoverflow连接

if val, ok := dict["foo"]; of {
	//...   
}

或者

_, ok := dict["foo"]
if ok {
    //...
}