GO learning - 002 Const Iota


GO learning - 002 Const Iota

package main

import "fmt"

// const 来定义枚举类型
const (
	BEIJING = 10 * iota
	SHANGHAI
	SHENZHEN
)

func main() {
	//常量(只读属性)
	const length int = 10
	fmt.Println(length)

	fmt.Println(BEIJING)
	fmt.Println(SHANGHAI)
	fmt.Println(SHENZHEN)

}
10
0
10
20

Author: Liang Junyi
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Liang Junyi !
  TOC