Hi, I have a Java API that has:
@Nullable <T> T findOne()
Now there is some discussion (being a Java API) that it should migrate towards:
<T> Optional<T> findOne()
Now thus far I personally have had the preference for the Java API to just return the type and for that return type to be annotated with @Nullable. In Kotlin it knows this is a nullable type and treats it as you’d expect (compiler enforcing null checking etc) … so to me this is all good and consistent with Kotlin usage.
I wonder if I am missing something. Are there arguments for returning Optional … for people using Kotlin? Are there areas where people like using Optional in Kotlin?
I have read the related discussion at: Proposal for the Option/MayBe datatype