79521709

Date: 2025-03-20 01:40:39
Score: 1.5
Natty:
Report link

One way to achieve this with Java Optional type:

public void f() {
    final int a = Optional.<Integer>empty().orElseGet(() -> {
        try {
          return operationCanThrow();
        } catch(final Exception e) {
          return 42;
        }
    });
}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Alex Diaz