Please review this changeset that introduces a new no-arg method
orElseThrow() to Optional, as a preferred alternative to the get()
method.

This looks good. The naming is consistent and I think better than the
"getWhenPresent" proposed in the original thread.

i agree with Alan.

Having a name that starts with "get" as the great advantage as to be visible in 
the IDE completion box just after the method get() so it will help people to transition 
from get() to getWhenPresent()

I'm not sure whether you're agreeing or disagreeing. :-)

The current proposal is for orElseThrow().

Having a method that starts with "get" (such as "getWhenPresent" or "getOrThrow") is indeed helpful when doing auto-completion, but it sort-of starts to create a new family of get- methods that overlap with the existing orElse- methods in an odd way. I think the no-arg orElseThrow() fits better with the existing three orElse- methods. This leaves get() as the outlier, which is ok if we maybe eventually deprecate it.

BTW, i do not see the point to not deprecate get() at the same time.

Much of the resistance to the earlier proposal was about deprecation of get(), so I wanted to set that aside in order to proceed with introduction of this alternative.

s'marks

Reply via email to