package main

import (
    "fmt"
)

const (
    a = 'A'
    b
    c = iota
    d
)

func main() {
    fmt.Println(a)
    fmt.Println(b)
    fmt.Println(c)
    fmt.Println(d)
}

 

[ /dinglicom/gowork/project/test/ ] # go run test1.go
[ `go run test1.go` | done: 641.241905ms ]
    65
    65
    2
    3

 

 

以定义常量的顺序次数有关系,

递增加1,再每个常量表达式组会初始化重新计数

相关文章:

  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-02-26
  • 2021-08-09
  • 2022-12-23
  • 2021-11-15
猜你喜欢
  • 2021-08-27
  • 2022-12-23
  • 2021-06-02
  • 2021-09-27
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
相关资源
相似解决方案