Hacker News new | past | comments | ask | show | jobs | submit login

It does makes quite a bit of sense, especially in the case where all those enums end up being processed by one single private function, such as "configureServer(config: ConfOption) ". (i'm refering to the linked post by Dave cheney here)

I spent a bit more time on the problem, and now i'm pretty sure it is also not solvable "cleanly" in swift, because it actually would need to model some kind of constraints over the accepted values of a type for a parameter.

Something like get(opt: Options<restrictedTo [.prefix, .revision]>... )

Otherwise you'll need to manually create a subenum, and manually compare cases from the original one with the sub one.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: