|
|
|
|
|
by randomdata
1491 days ago
|
|
> This assertion is nowhere in the Go spec, not even implicitly. The first line explicitly defines their use for defining enums. The only way it could be more clear would be to define enum, but that should be unnecessary given that the definition is usually well established, although certainly a couple of languages have tried to muddy those waters in recent times. > `iota` is a convenience sequence generator More importantly, it defines a set of values. The set is what differentiates an enumeration from a general bag of constants. C reaches for a enum keyword instead, but they achieve the same result of establishing a set. > Go still does not have enums It has enums. It doesn't have sum types. Yes, some languages call sum types enums, which is no doubt where your confusion lies. |
|