当前位置:网站首页>《Go题库·15》go struct 能不能比较?
《Go题库·15》go struct 能不能比较?
2022-06-30 17:32:00 【GolangRoadmap】
*「题目解析」GOLANG ROADMAP社区
*
「答案」(engine)
需要具体情况具体分析,如果struct中含有不能被比较的字段类型,就不能被比较,如果struct中所有的字段类型都支持比较,那么就可以被比较。
不可被比较的类型: ① slice,因为slice是引用类型,除非是和nil比较 ② map,和slice同理,如果要比较两个map只能通过循环遍历实现 ③ 函数类型
其他的类型都可以比较。
还有两点值得注意:
结构体之间只能比较它们是否相等,而不能比较它们的大小。 只有所有属性都相等而属性顺序都一致的结构体才能进行比较。
边栏推荐
- iCloud照片无法上传或同步怎么办?
- 又一篇CVPR 2022论文被指抄袭,平安保险研究者控诉IBM苏黎世团队
- SaaS project management system solution for the financial service industry helps enterprises tap a broader growth service space
- 【TiDB】TiCDC canal_ Practical application of JSON
- Another CVPR 2022 paper was accused of plagiarism, and Ping An insurance researchers sued IBM Zurich team
- countdownlatch 和 completableFuture 和 CyclicBarrier
- LeetCode之合并二叉树
- Summary of methods for offline installation of chrome extensions in China
- Development and construction of NFT mining tour gamefi chain tour system
- Dlib库实现人脸关键点检测(Opencv实现)
猜你喜欢

countdownlatch 和 completableFuture 和 CyclicBarrier

Helping the ultimate experience, best practice of volcano engine edge computing

Solution of enterprise supply chain system in medical industry: realize collaborative visualization of medical digital intelligent supply chain

It's not easy to say I love you | use the minimum web API to upload files
Do you really understand the persistence mechanism of redis?

If you want to learn software testing, you must see series, 2022 software testing engineer's career development

AI chief architect 10-aica-lanxiang, propeller frame design and core technology

漏洞复现----37、Apache Unomi 远程代码执行漏洞 (CVE-2020-13942)

Deep learning compiler understanding

What if the apple watch fails to power on? Apple watch can not boot solution!
随机推荐
小程序容器技术,促进园区运营效率提升
「经验」浅谈聚类分析在工作中的应用
助力极致体验,火山引擎边缘计算最佳实践
Tensorflow2 ten must know for deep learning
What if icloud photos cannot be uploaded or synchronized?
PHP uses queues to solve maze problems
麻烦问下 Flink支持同步数据到 sqlserver么
Vs Code treeview TreeView
ASP. Net password encryption and password login
MySQL找不到mysql.sock文件的臨時解
Research on the principle of Tencent persistence framework mmkv
Sword finger offer 16 Integer power of numeric value
Merged binary tree of leetcode
OneFlow源码解析:算子签名的自动推断
LeetCode动态规划经典题(一)
Advanced embedded application of uni app [day14]
Troubleshooting MySQL for update deadlock
国内离线安装 Chrome 扩展程序的方法总结
Deep learning compiler understanding
Customer relationship CRM management system based on SSH