I am trying to understand the difference between the
The description for the
method is "Return the value if present, otherwise return other."
While, the description for the
method is "Return the value if present, otherwise invoke other and return the result of that invocation."
method takes a Supplier functional interface, which essentially does not take any parameters and returns
In which situation would you need to use
? If you have a method
why wouldn't you just do
optional.orElseGet(() -> myDefault())
It does not seem that
is postponing the execution of the lambda expression to some later time or something, so what's the point of it? (I would have thought that it would be more useful if it returned a safer
never throws a
always returns true... but evidently its not, it just returns
Is there some other difference I am missing?