Answers for "golang const iota"

Go
1

golang const iota

const (
	C0 = iota
	C1
	C2
)
fmt.Println(C0, C1, C2) // "0 1 2"
Posted by: Guest on March-23-2021
0

golang iota enum

type Direction int

const (
    North Direction = iota
    East
    South
    West
)

func (d Direction) String() string {
    return [...]string{"North", "East", "South", "West"}[d]
}
Posted by: Guest on October-20-2020

Browse Popular Code Answers by Language