Quick actions

cmd+k|ctrl+k

Navigation

Languages

Constants / iota / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-03-26T10:03:12Z

Updated

2019-03-26T10:03:12Z

package main

import "fmt"

func main() {
	const ( // iota is reset to 0
		a = 1 << iota // a == 1
		b = 1 << iota // b == 2
		c = 3         // c == 3  (iota is not used but still incremented)
		d = 1 << iota // d == 8
	)
	fmt.Printf("a: %d, b: %d, c: %d, d: %d\n", a, b, c, d)
}
INFO