-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No defaults in enum switch #131
Comments
+1 we also make sure to never use the |
I'd love this feature also. |
I think this is a good rule to have, but it would be challenging to detect when the variable being switched on is an enum. |
I would love to have this too :) |
This would be great! |
you mentioned that it would be challenging to detect when the variable being switched on is an enum. enum MyEnum {
case one, two
}
let myEnum = MyEnum.two
switch myEnum {
case .one: break
↓default: break
} Please let me know whether you think this could work, I would be happy to implement this rule. |
I find the exhaustive
enum
warnings from the compiler super helpful. It ensures that whenever a newenum
case is added, everyswitch
statement is updated. But this won't work well withdefault
. Often times thedefault
is there as an easy way to group behaviour for the other cases at the time. I'd like to see this added as a warningThe text was updated successfully, but these errors were encountered: