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

Aviad Zer duke at openjdk.org
Mon Jan 20 11:30:37 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.

Thank you for reviewing my PR and providing feedback.

I apologize for not discussing this enhancement on the mailing list prior to submitting the PR. My focus was on extending Math.min for multiple parameters to simplify code readability and reduce nested calls. 

Expanding Scope:
I chose to focus on min() for this initial contribution to keep the proposal small and manageable. However, I understand the value of symmetry in the API and would be open to extending similar functionality to **max()** and other related methods, such as addExact(), if the community agrees.

CSR Requirement:
Thank you for pointing out the need for a CSR. I would appreciate any guidance on how to file a CSR and the next steps to ensure that this enhancement aligns with OpenJDK’s standards and processes.

I look forward to your guidance and continuing to improve this contribution

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

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


More information about the core-libs-dev mailing list