-
Notifications
You must be signed in to change notification settings - Fork 73
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
Rule to recommend if-else construct instead of match clause #545
Comments
janus
added a commit
to janus/FSharpLint
that referenced
this issue
May 2, 2022
It improves code readability. Fixes: fsprojects#545
janus
added a commit
to janus/FSharpLint
that referenced
this issue
May 3, 2022
It improves code readability. Fixes: fsprojects#545
janus
added a commit
to janus/FSharpLint
that referenced
this issue
May 3, 2022
It improves code readability. Fixes: fsprojects#545
parhamsaremi
pushed a commit
to parhamsaremi/FSharpLint
that referenced
this issue
Nov 21, 2022
It improves code readability. Fixes: fsprojects#545
I think match is very readable if you have used to it. match a when
| Some x when x > 21 -> x
| _ -> 21 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
If a match clause only has 2 cases, and the last case is _, then the whole thing can be converted into a simple if-then-else block, which is more readable.
Test1:
Should throw warnings.
Test2:
Should not throw warnings (because it has 3 cases, not 2).
Test3:
Should not throw warnings (because its last case is not _).
Test4:
Should not throw warnings (because its first case is not a single element, so the casting is useful).
The text was updated successfully, but these errors were encountered: