“Golang const iota” Kod odpowiedzi

Golang const iota

const (
	C0 = iota
	C1
	C2
)
fmt.Println(C0, C1, C2) // "0 1 2"
knavels

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]
}
Fragile Frog

Odpowiedzi podobne do “Golang const iota”

Pytania podobne do “Golang const iota”

Więcej pokrewnych odpowiedzi na “Golang const iota” w Go

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu