Iota constant in Go
When we are only interested in representing the allowed value of something, but we don’t care what those actual values are, we can use the iota
constant. It will get the value 0, and successive constants will get successively increasing values: 1, 2, 3…
1type Category int
2
3const (
4 CategoryAutobiography Category = iota
5 CategoryLargePrintRomance
6 CategoryParticlePhysics
7)
References
- John Arundel, For the Love of Go
#programming #constants #values #define #golang #variables #sets