Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

iota

  • iota

  • iota (increment by 1 on every use in every constant block of var) enumeration

package main

import (
	"fmt"
)

const (
	a = iota
	b = iota
	c = iota
)

const (
	d = iota
	e
	f
)

func main() {
	fmt.Println(a)
	fmt.Println(b)
	fmt.Println(c)
	fmt.Println()

	fmt.Println(d)
	fmt.Println(e)
	fmt.Println(f)
}
0
1
2

0
1
2