This page is about the switch statement. Is it going to be expanded to include documentation about switch expression (https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#more-patterns-in-more-places) or is it going to be a separate page?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
I would gather it would be a different page under that same parent. Considering they are different selection mechanisms and it discusses Switch Expression vs Switch Statement.
@BillWagner has a project tracking C# 8.0 updates. I'll add this issue to that project and let @BillWagner take it on from here.
Thanks!
GitHub is acting weird. I can't set backlog as the milestone..
I set the milestone to November. I want to update all the reference pages between now and .NET Core 3.1.
It is end of December and no documentation on switch expression! Come on guys, you could better.
@KUTlime currently the switch expression is briefly explained at the "What's new in C# 8.0" page:
https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#switch-expressions
What, if any, do you think is missing there?
@pkulikov You just said it - briefly.
What is missing:
when conditionI know how to do it. I'm trying to say that this could be helpful for newcomers to C# 8.0. The switch expressions are more or less equal to the switch statements. The switch expression deserves their own page with more examples and a structure as the switch statement page.
@KUTlime thank you!
I wonder what made you put the example with use of ternary operator first? Why particularly this operator?
Officially, I chose from-the-most-simple-use scenario ordering.
Unofficially, last two hours, I was analysing a weir problem in VS when switch expression and ternary operator was used. This brought me to this page. The problem was caused by R# and solved by update to the R# latest version but for a brief moment, I was convinced that ternary operator can't be used together with switch expression simply because of the fact that I wasn't able to find any proof that I'm wrong or vice versa.
By the way, the following C# 8.0 pattern matching tutorial contains examples with the switch expression:
https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/pattern-matching
That page can be a good way to learn about the switch expression, while there is no dedicated switch page.
In particular, it covers:
- example with use of
whencondition- example with pattern matching
I'm starting to work on this, and it's exposing some flaws in the current organization of the language reference. I'd like feedback on the following ordered set of thoughts:
=> instead of : and breakThat leads me to this conclusion:
Is this the right time to rename the "Operators" section "Expressions", and add the new article there?
I propose "Yes".
If so, which of the sub-sections should be named
I propose renaming these:
Should there be others? Should some be dropped?
/cc @pkulikov for input.
@BillWagner I agree mostly with you and have had the similar thoughts about expressions.
Is this the right time to rename the "Operators" section "Expressions", and add the new article there?
Yes, however I suggest to rename the section to Operators and expressions (or Expressions and operators). What do you think?
As for renamings, I don't think ?: should be renamed, as it's widely known as "ternary operator", also "C# conditional operator" is more checked in Google than "C# conditional expression".
As for the member access, I think it should be "Member access operators and expressions", because invocation () is more an expression, but range .. is commonly referred as an operator.
With other two I agree and have some more, so:
What do you think?
As soon as we agree on renamings, I would like to submit the corresponding PR. There we can discuss the remaining minor details if any, and after it's merged, there are no blocks for the switch expression. Is that fine with you?
What do you think?
I like your additions @pkulikov
submit the corresponding PR. There we can discuss the remaining minor details if any, and after it's merged, there are no blocks for the switch expression. Is that fine with you?
Great plan. I agree. I'll start working on a draft, and then rebase once I've seen your PR.