#Is it possible to iterate over all enum values in GoLang?

13 messages · Page 1 of 1 (latest)

hard badge
#

Let's say there are three enumerations A, B and C..Is it possible to iterate through all of them?

acoustic canyon
#

there is iota but it's just a cleaver constant trick so no

hard badge
acoustic canyon
#

You don't iterate over types (unless you are using reflect but you don't want to do that)

hard badge
hard badge
acoustic canyon
hard badge
acoustic canyon
#

it's very great because if you add more elements in the future it's gonna keep compiling even tho you are missing some

#

an alternative is to defined a global next to the const block but not everyone does this