by jryan49 · 8y ago · 0 comments
.where(p -> p.getCategory == 2 || p.getCategory == 5 && isProductUnderDiscount(p))
and if (product.getCategory() == 2 || product.getCategory() == 5) {
boolean yes = isProductUnderDiscount(product);
not functionally equivalent due to && precedence? .where(p -> p.getCategory == 2 || p.getCategory == 5 && isProductUnderDiscount(p))
is equivalent to: if (product.getCategory() == 2 || ( product.getCategory() == 5 && isProductUnderDiscount(product) );
The extra set of parentheses are not needed due to precedence, but have been included for clarification. (product.getCategory() == 2 || product.getCategory() == 5) && isProductUnderDiscount(product)