Replies: 7 comments
-
I think that the parenthesis are useful here for readability, not sure why people want to get rid of them but not needing a |
Beta Was this translation helpful? Give feedback.
-
@eyalsk match cannot be used as an statement (except with a discard if it doesn't return void). Not requiring break here is because there is only a single section so the control will fall out of switch anyways. |
Beta Was this translation helpful? Give feedback.
-
Assuming you are thinking just of return specialType match (
case SpecialType.System_Byte:
case SpecialType.System_SByte:
case SpecialType.System_Int16:
case SpecialType.System_UInt16:
case SpecialType.System_Int32:
case SpecialType.System_UInt32:
case SpecialType.System_Int64:
case SpecialType.System_UInt64: true
case * : false
); Alternatively, with an return specialType match (
case SpecialType.System_Byte or
SpecialType.System_SByte or
SpecialType.System_Int16 or
SpecialType.System_UInt16 or
SpecialType.System_Int32 or
SpecialType.System_UInt32 or
SpecialType.System_Int64 or
SpecialType.System_UInt64: true
case * : false
); |
Beta Was this translation helpful? Give feedback.
-
@DavidArno Assuming that you are not returning a value e match { .. }; // ERROR Even with a discard, you can't use void returning methods, _ = e match { /* .. VoidMethod() .. */ }; Though that would probably work because of dotnet/roslyn#17674 😄 |
Beta Was this translation helpful? Give feedback.
-
@alrz Got'cha, the only issue I have with this is mostly syntactic. :) |
Beta Was this translation helpful? Give feedback.
-
This is just syntactic. I really hope that |
Beta Was this translation helpful? Give feedback.
-
@alrz Yeah I realized that but I said that because I don't want to lose the parenthesis, I know it's subtle but for me, I'm used to having them everywhere so yup I'd really love the match expression to have a statement form over this. :) Feels like I'm ranting over nothing. 😄 |
Beta Was this translation helpful? Give feedback.
-
From C++, (dotnet/roslyn#11292)
->
The single section switch doesn't need
break
and it would belong to an enclosing statement (if any).Beta Was this translation helpful? Give feedback.
All reactions