GO learning - 002 Const Iota


GO learning - 002 Const Iota

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)

}
1
2
3
4
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