如何在Go中检查地图是否包含密钥?

允我心安 提交于 2020-08-12 08:32:20

问题:

I know I can iterate over a map m by, 我知道我可以在地图迭代m的,

for k, v := range m { ... }

and look for a key but is there a more efficient way of testing a key's existence in a map? 并寻找钥匙,但是有没有更有效的方法来测试地图中钥匙的存在?

I couldn't find the answer in the language spec . 我在语言规范中找不到答案。


解决方案:

参考一: https://stackoom.com/question/8bOp/如何在Go中检查地图是否包含密钥
参考二: https://oldbug.net/q/8bOp/How-to-check-if-a-map-contains-a-key-in-Go
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!