iota 常量自动生成器,每隔1行自动加1
func main() {
const (
a = iota
b
c
)
fmt.Println(a, b, c)
// 结果为1,2,3
}
同一行,值一样
func main() {
const (
a = iota
b1, b2, b3 = iota, iota, iota
c = iota
)
fmt.Println(a, b1, b2, b3, c)
// 结果0,1,1,1,2
}
iota 常量自动生成器,每隔1行自动加1
func main() {
const (
a = iota
b
c
)
fmt.Println(a, b, c)
// 结果为1,2,3
}
同一行,值一样
func main() {
const (
a = iota
b1, b2, b3 = iota, iota, iota
c = iota
)
fmt.Println(a, b1, b2, b3, c)
// 结果0,1,1,1,2
}