My function takes an optional parameter,
type, which is used to filter through a collection. However, the filter should only apply if the parameter is passed in (in other words, non-null). If the filter is not passed in, it should not be applied. How can I write my logic to reflect this? What I have now is -
if( other conditions && ( Type == null || (Type != null && Order.Type == Type ) ) ) return val += Order;
But this feels clunky and wrong. Is there a way I can simplify my logic here?