golang 使用 iota

iota是golang语言的常量计数器,只能在常量的表达式中使用golang iota在const关键字出现时将被重置为0(const内部的第一行以前),const中每新增一行常量声明将使iota计数一次(iota可理解为const语句块中的行索引)code const ( a = iota b c d ) fmt.Println(a) //0 fmt.Println(b)
相关文章
相关标签/搜索