Replies: 5 comments
-
I had not thought about that. Thanks for the pointer to actual usage of this (copied that snippet below): (constant, expression) =
IsConstant(expression1) ? (expression1, expression2) :
IsConstant(expression2) ? (expression2, expression1) :
default((TExpressionSyntax, TExpressionSyntax)); The current feature only supports either (1) a tuple literal (which will get some type inference), (2) a tuple type (which is trivial to deconstruct), or (3) some type with FYI @gafter |
Beta Was this translation helpful? Give feedback.
-
That specific case already seems to work. This code compiles fine on Roslyn master: (constant, expression) =
IsConstant(expression1) ? (expression1, expression2) :
IsConstant(expression2) ? (expression2, expression1) :
default; |
Beta Was this translation helpful? Give feedback.
-
Right. A ternary does have a type, whence the |
Beta Was this translation helpful? Give feedback.
-
Still I think |
Beta Was this translation helpful? Give feedback.
-
Perhaps, it would be better to zero-out some variables like this: |
Beta Was this translation helpful? Give feedback.
-
@alrz commented on Mon May 15 2017
Version Used: master
Steps to Reproduce:
Expected Behavior: compile with no error.
Actual Behavior: error CS8131: Deconstruct assignment requires an expression with a type on the right-hand-side.
@alrz commented on Mon May 15 2017
@jcouv Can this be special cased? would come in handy sometime.
Beta Was this translation helpful? Give feedback.
All reactions