Go语言 之iota枚举

// iota枚举类型 project main.go
package main

import (
    "fmt"
)

func main01() {
    const (
        a = iota // 0
        b = iota // 1
        c = iota // 2
    )
    fmt.Println(b)
}

func main() {
    // iota 是根据行数来的
    const (
        a = 10
        b = 11
        c = iota // 2
    )
    fmt.Println(c)
}

 

posted @ 2019-06-29 16:17  样子2018  阅读(119)  评论(0编辑  收藏  举报