2 ms·
Definitely. For me, the main use case of Optional is to provide a way for programmers to express the semantic fact that "there is no such object" without resort
by ralmeida 11y ago
Definitely. For me, the main use case of Optional is to provide a way for programmers to express the semantic fact that "there is no such object" without resorting to null.
Doing this leads to checking if (obj == null) for dealing with the semantic case that the object is not present, but other kinds of failure may cause obj to be null, but should be treated differently (for being a lower-level issue, for example).
So, Optional<T> is basically a way to differentiate between different types of nullity.