1. Home
  2. Docs
  3. golang
  4. 基础
  5. iota

iota

iota 可以做更多事情,而不仅仅是 increment。更精确地说,iota 总是用于 increment,但是它可以用于表达式,在常量中的存储结果值。

  • 换下一行才会自增
  • 不同的const重新自增
  • 同一个const与其他的常量那么这个常量会顶替一个值
const(
    a = iota
    b = iota
    f = iota
)

const(
    c = iota
    d = iota
)
// 打印常量
0
1
2
0
1

相关资料

iota

Was this article helpful to you? Yes No

How can we help?