如何在Go中检查地图是否包含密钥? - How to check if a map contains a key in Go?
2020-07-10 06:55
381 查看
问题:
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
相关文章推荐
- How to Check if an Array Contains a Value in Java Efficiently?---reference
- How to Check if an Array Contains a Value in Java Efficiently?
- How to Check if an Array Contains a Value in Java Efficiently?
- 检查数组中是否包含特定值(Check if an array contains a certain value)
- 如果SQL Server中存在表,如何删除表? - How to drop a table if it exists in SQL Server?
- How to check if the silverlight application is in design mode?
- [Groovy] How to check if element in groovy array/hash/collection/list?
- grails - How to check if element in groovy array/hash/collection/list? - Stack Overflow
- How to know is the file exist in C++ - 在C++中如何判断文件是否存在
- How to check if a Number is Positive or Negative in Java - Interview Question
- [html] 本地如何测试google map -- How to test google map in localhost
- How to check if a date is a valid date in Sql Server 2005
- Android How to Check if the App is in Background
- How to fix 'Inconsistency detected by ld.so: dl-version.c: 224: _dl_check_map_versions'
- How can I check if one string contains another substring in JavaScript?
- Go语言的map如何判断key是否存在
- How to sort a Map<Key, Value> on the values in Java?
- How to Iterate Over a Map in Java?(如何遍历Map)
- How to check in Windows if you are using UEFI
- Map.containsKey/Map.containsValue方法——判断Map集合对象中是否包含指定的键名