java - Is there a method reference in JDK for subtracting doubles? -


double::sum method reference adding doubles, ie. (a,b) -> a+b.

why there not method reference minus in jdk? i.e. (a,b) -> a-b?

the primary purpose of methods double.sum aid use cases reduction or arrays.parallelprefix since minus not associative function, not appropriate use case.

adding 3rd party library dependencies sake of such simple method, not recommended. keep in mind, can create own method, if prefer named methods on lambda expressions.

e.g.

static double minus(double a, double b) {     return a-b; } 

and using myclass::minus informative thirdpartyclass::minus


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -