Skip to content

Instantly share code, notes, and snippets.

@controlflow
Last active Nov 16, 2020
Embed
What would you like to do?
if (pattern is IPatternWithDesignation withDesignation)
{
var existingDesignation = withDesignation.Designation;
if (existingDesignation != null && !(existingDesignation is IDiscardDesignation)) return false;
}
// after "Merge sequential patterns"
if (pattern is IPatternWithDesignation withDesignation)
{
var existingDesignation = withDesignation.Designation;
if (existingDesignation is { } and not IDiscardDesignation) return false;
}
// after "Replace `and` with `or`"
if (pattern is IPatternWithDesignation withDesignation)
{
var existingDesignation = withDesignation.Designation;
if (existingDesignation is not (null or IDiscardDesignation)) return false;
}
// inline variable, merge ifs, merge sequential patterns into recursive
if (pattern is IPatternWithDesignation { Designation: not (null or IDiscardDesignation) })
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment