Skip to content

Instantly share code, notes, and snippets.

@controlflow
Created January 27, 2019 16:44
Show Gist options
  • Save controlflow/fb98f117178a53c6a0732da6de24abd4 to your computer and use it in GitHub Desktop.
Save controlflow/fb98f117178a53c6a0732da6de24abd4 to your computer and use it in GitHub Desktop.
if (myConditionalExpression.ThenResult is IRefExpression thenRefExpression && thenRefExpression.Expression != null)
{
thenRefExpression.ReplaceBy(thenRefExpression.Expression);
}
else if (myConditionalExpression.ElseResult is IRefExpression elseRefExpression && elseRefExpression.Expression != null)
{
elseRefExpression.ReplaceBy(elseRefExpression.Expression);
}
if (myConditionalExpression.ThenResult is IRefExpression { Expression: { } thenOperand } thenRefExpression)
{
thenRefExpression.ReplaceBy(thenOperand);
}
else if (myConditionalExpression.ElseResult is IRefExpression { Expression: { } elseOperand } elseRefExpression)
{
elseRefExpression.ReplaceBy(elseOperand);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment