I have the following statement to check if a Vector2D is within a box, and IntelliJ gives me a warning: "if statement can be simplified".
if(point.x < minX || point.x > maxX || point.y < minY || point.y > maxY)
return false;
How can I simplify this?
I don't see any possible simplification. I would just ignore the warning.
Update: However, if you method look like this:
if(point.x < minX || point.x > maxX || point.y < minY || point.y > maxY)
return false;
return true;
You might change it to this:
return !(point.x < minX || point.x > maxX || point.y < minY || point.y > maxY);
Or even:
return point.x >= minX && point.x <= maxX && point.y >= minY && point.y <= maxY;
I don't know if this is "simplified" for humans.