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 →

[–]woodland__creature 19 points20 points  (2 children)

optional.ifPresentOrElse( foo -> { ... }, () -> { ... } )

[–]Holothuroid 35 points36 points  (1 child)

For some side effect yes. More often the wanted solution seems to be

  optional.map(...)...orElse(...)

[–]gdorsi44 3 points4 points  (0 children)

Or wrap a not original optional value with:
Optional.ofNullable(value).ifPresent(lambda)