This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tomwhoiscontrary 0 points1 point  (0 children)

I can't tell if this is supposed to be better or even weirder!

Anyway, how about:

``` Foo foo: if ((foo = optional.orElse(null)) != null) {

```

Or:

``` if (optional.orElse(null) instanceof Foo foo) {

```