Why is LaunchAtLogin.swift implemented as enum (and not as class or struct)?
mixtly87 opened this issue · 1 comments
Hi @sindresorhus . First of all I think your design of LaunchAtLogin is great!
But I'm just curious why is it implemented as enum?
My impression was that enums should be used to define a common type for a group of related values (case items). I occasionally keep seeing enum being used as much more, like in your example.
I was just wondering what is the benefit? Were there any limitations to implementing logic via class or struct approach?
I have a feel that using enums in the way you did is kind of abusing enums. But it may be well since I come from the Java world originally. Or if you can point to some article were it is justified or encouraged to use enums the way you did.
Note: I'm aware this question is not an Issue in classical sence, I was just curious in the discussion.
Thank you.
enum
with static properties is the common convention for imitating namespaces (which Swift lacks).
https://www.swiftbysundell.com/articles/powerful-ways-to-use-swift-enums/