Answers for "golang iota enum"

Go
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