> On 9 Oct 2015, at 02:31, John Rose <john.r.r...@oracle.com> wrote:
> 
> It may be instructive to link nulls to Optionals by encoding null-ness using 
> Optional:
> 
> <T> T nonNullElse(T x, T y) := Optional.ofNullable(x).orElseGet(() -> 
> Optional.ofNullable(y).get())
> 

And with the new Optional.or [*] to be added soon the above could be expressed 
as:

  :=  Optional.ofNullable(x).or(() -> Optional.ofNullable(y))

Paul.

[*] i am searching for a better name, but don’t want to derail this thread with 
such a discussion.

> <T> T nonNullElseGet(T x, Supplier<T> y) := 
> Optional.ofNullable(x).orElseGet(() -> Optional.ofNullable(y.get()).get())
> 


Reply via email to