package main
import "fmt"
//const 来定义枚举类型
const(
BEIJING = 0
SHANGHAI = 1
SHANDONG = 2
)
const(
//可以在 const() 添加一个关键字 iota,每行iota都会累加1,第一行的iota的默认值是0
//iota只能在const一起使用
JINAN = iota //iota = 0
QINGDAO //iota = 1
TAIAN //iota = 2
)
const(
AA = 10*iota //iota = 0
BB //iota = 1
CC //iota = 2
)
const(
a,b = iota+1,iota+2 // iota = 0 ,a = 1,b = 2
c,d //iota = 1,c = 2, d = 3
e,f //iota = 2,e = 3, f = 4
g,h = iota*2,iota*3 //iota = 3,g = 6,h = 9
i,k //iota = 4,i = 8,k = 12
)
func main() {
//常量(只读属性,不允许修改)
const length int = 10
fmt.Println(length)
fmt.Println("JINAN = ",JINAN) //JINAN = 0
fmt.Println("QINGDAO = ",QINGDAO) //QINGDAO = 1
fmt.Println("TAIAN = ",TAIAN) //TAIAN = 2
fmt.Println("AA = ",AA) //AA = 0
fmt.Println("BB = ",BB) //BB = 10
fmt.Println("CC = ",CC) //CC = 20
}