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

Martin Desruisseaux duke at openjdk.org
Mon Jan 20 11:50:35 UTC 2025


On Mon, 20 Jan 2025 11:43:13 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.
>
> Aviad Zer has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update Math.java by adding extended max function

Aren't `Math.min(values)` methods duplicating `Arrays.stream(values).min()`? Except for the `float` type, for which there is no stream.

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

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


More information about the core-libs-dev mailing list