Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The code ends up looking like:

  Optional<Integer> foo;

  //....

  if (foo != null) {
      foo.and_then(new Consumer () {
            function accept(Integer foo) {

            }
      });
  }


I would never assign null to an Optional nor use a library that returned one.

To ensure assignment before use make it final.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: