Unpopular opinion: I like switch statements
Unpopular opinion: I like switch statements.
1. Switch clearly conveys "One of these cases applies" at a glance.
2. Switch's default case encourages me to consider unhandled cases. Switch helps me remember to throw an error in cases where there's no logical default.
Oh, and C# 8's switch expression is 🔥. Check out this comparison.
More: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#switch-expressions
