RFR: JDK-8348030 : Extend Math.min and Math.max to support multiple parameters

Aviad Zer duke at openjdk.org
Mon Jan 20 11:43:13 UTC 2025


On Wed, 15 Jan 2025 14:26:32 GMT, Aviad Zer <duke at openjdk.org> wrote:

> This change extends the Math.min function to support multiple parameters, improving its usability and code readability.
> 
> Previously, finding the minimum value among multiple variables required using nested Math.min calls or converting the variables into an array and iterating through it. This enhancement provides a more intuitive and straightforward approach to achieve the same result.
> 
> Benefits:
> 
> Simplifies code by eliminating the need for nested Math.min calls.
> Enhances readability, especially when comparing multiple values.
> Offers consistency with existing Math.min usage patterns.

I have updated the PR to include an extended Math.max function, similar to the changes made for Math.min. This ensures consistency in the API and provides a unified approach for handling multiple parameters across both methods. Additionally, I have updated the PR title to reflect these enhancements. Please let me know if further changes are required.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/23138#issuecomment-2602194597


More information about the core-libs-dev mailing list