package main
import (
"fmt"
)
// 使用const 来定义一个Color的枚举
type Color int
const (
RED Color = iota
BLACK
)
type Tree struct {
Data int //数据
Color Color //颜色
}
func main() {
t1 := rbtree.Tree{1,RED}
fmt.Println(t1)
}
//{1 0}
Golang 使用const定义枚举
最新推荐文章于 2024-05-15 11:02:15 发布