|
|
|
|
|
by masklinn
1491 days ago
|
|
> It has enums, but they are C-style enums rather than sum types. It doesn't. The closest it has is TFA's second example: type FlagID int
const (
FooBar FlagID = iota
FizzBuzz
)
which is the underlying behaviour of C enums, but not actually that. Crucially it does not at any point hint or imply the set could be in any way closed.That it doesn't have C-style enums is a point in its favour, I would say. Not much of a point, mind, but still... |
|
It does. By definition, an enum is simply a set of named values, which you code example provides, and is behaviourally the same as C.
> it does not at any point hint or imply the set could be in any way closed.
While true, that is a feature of sum types, which I already indicated Go does not have. This is slightly different to enums.