3 ms·
&& precedence mans that the && arguments are bound first, so: .where(p -> p.getCategory == 2 || p.getCategory == 5 && isProductUnderDiscount(p)) is equiva
by taserian 8y ago
&& precedence mans that the && arguments are bound first, so:
.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.
- jonhohle 8y agoWhich is not functionally the same as OPs second example which would be equivalent to (product.getCategory() == 2 || product.getCategory() == 5) && isProductUnderDiscount(product)