Tag Info

New answers tagged

0

It's often cleaner to avoid the null altogether by creating two functions: one with the filter and one without. The former can call the latter, like: if (Order.Type == Type) return nonFilterFunction(...) This style follows the Single Responsibility Principle by having one function do only filtering and one function doing the other stuff. It allows ...


4

The OP has stated in a comment that the language used has short-circuiting Boolean operators, so this could be written as: if( other conditions && ( Type == null || Order.Type == Type ) ) return val += Order;



Top 50 recent answers are included