什么是 Golang Comparable Types

栏目: Go · 发布时间: 6年前

内容简介:Golang 中有很多时候要用到comparable types,例如比较struct的时候,例如map里的 key。弄清楚有哪些类型是comparable的非常重要。

Golang 中有很多时候要用到comparable types,例如比较struct的时候,例如map里的 key。弄清楚有哪些类型是comparable的非常重要。

https://golang.org/ref/spec#Comparison_operators

  • Boolean values
  • Integer values
  • Floating point values
  • Complex values
  • String values
  • Pointer values
  • Channel values
  • Interface values
  • Struct values are comparable if all their fields are comparable
  • Array values are comparable if values of the array element type are comparable
  • A value x of non-interface type X and a value t of interface type T are comparable when values of type X are comparable and X implements T

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

认知盈余

认知盈余

[美] 克莱·舍基 / 胡泳、哈丽丝 / 中国人民大学出版社 / 2011-12 / 49.80元

“互联网革命最伟大的思考者”克莱•舍基 继《未来是湿的》之后最新力作 看自由时间如何变革世界的未来 如果说《未来是湿的》揭示的是“无组织的组织力量”, 那么《认知盈余》揭示的就是 “无组织的时间力量”。 腾讯董事会主席兼首席执行官马化腾首度亲笔作序倾情推荐 克莱•舍基说,美国人一年花在看电视上的时间大约2 000亿个小时,而这几乎是2 000个维基百科项目一年所需要的......一起来看看 《认知盈余》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具