switch default to _ ? So disturbing.
Since switch exists, we always use the "default" keywords for default case. Switching "default" to _ is very disturbing, specially when still using the "switch" keywords. In C, default is "default", since always, in C++ default is "default", in Java default is... "default" (amazing), in C# 1 to 7 too, same in Javascript, Php, Go... There is some languages that doesn't use 'default' keywords, but it is not a majority (SQL, Haskell, Erlang, Ruby, or Python that even doesn't have a switch (no comments)). So using _ will break the C of C#, it will be so disturbing that some switch will use 'default', some other will use _, in the same language. Not advertised developers will consider it like an error, and will spend time to understand wtf is that character. Please reconsider the question, and keep the good old "default" with new switch expression, or better anything like a lambda character ("default" included), like in Erlang and Clojure .
Regards
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: a94537c5-754e-9dea-94a8-7573011f588c
- Version Independent ID: aba09118-22c5-2c6a-954a-b9659a9644ae
- Content: What's New in C# 8.0 - C# Guide
- Content Source: docs/csharp/whats-new/csharp-8.md
- Product: dotnet-csharp
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagn
I think the difference is that in a switch statement, you either write case pattern or default, while in a switch expression, you only write pattern. So it makes sense to use the discard pattern for the default, since using default would not actually be consistent.
Though C# 8.0 is going to be released very soon, so it's too late now to change that decision.
The docs do correctly explain the switch expression. I'll close this as no action is needed on the documentation.
To "switch expressions" mentioned here,
Instead of polluting the simple switch statement, Please introduce the keyword "map", something inline with F#.