A DESCRIPTION OF THE PROBLEM :
Optional's new ifPresentOrElse() method is an improvement over the previous if/else idioms used for Optional, but it is somewhat clunky to declare your "ifPresent" logic after the language "orElse". E.g.,
optional.ifPresentOrElse(System.out::println, System.out::println);
If, instead, you could chain off the result of ifPresent(), it would result in much more fluid code:
optional.ifPresent(System.out::println).orElse(System.out::println);
This could be accomplished by making ifPresent() return itself and adding an orElse() method to optional, or by adding a new return type to ifPresent() specifically for chaining.
Optional's new ifPresentOrElse() method is an improvement over the previous if/else idioms used for Optional, but it is somewhat clunky to declare your "ifPresent" logic after the language "orElse". E.g.,
optional.ifPresentOrElse(System.out::println, System.out::println);
If, instead, you could chain off the result of ifPresent(), it would result in much more fluid code:
optional.ifPresent(System.out::println).orElse(System.out::println);
This could be accomplished by making ifPresent() return itself and adding an orElse() method to optional, or by adding a new return type to ifPresent() specifically for chaining.