It seems for performance reasons OptionalDouble
does not simply extend Optional<Double>
? IMO, that's a perf concern that should not have leaked into SDK design but I digress.
As a library writer, which one should I expose to my users, Optional<T>
or OptionalT
? What factors would make me decide which one to use when?
EDIT: Based on the comments, elaborating my particular use case. I am writing a bridge to a Scala ML library so people can use it from Java 8+.
The boiled down Scala signature looks like this:
def flattenBy(f: Double => Option[Double]): List[Double]
For those not familiar with Scala, flattenBy
is a function that takes in another function from Double
to Option[Double]
and returns a List
of Doubles
.
What is the closest signature this maps to in Java 8?