Great article!
Theo Kallioras
81

Great question. Here we are just trying to create a namespace to put our constants in. Doesn’t really matter if it’s a struct or enum. However you wouldn’t want anyone to create an instance of your “namespace”.

struct Constants { ... }

If you define it as a struct, it’s possible to create an instance like Constants() (unless you make the initializer private) which wouldn’t be meaningful. With enums, this is not possible.

Like what you read? Give Göksel Köksal a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.