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

Even that seems way too much. The original would be much easier as:

  if (nullableVariable != null) {
      boolean success = nullableVariable.someMethodCall()
      if (success) {
          return success;
      }
  }
  return fallbackIfNullMethodCall();
And even that can be more concise if you prefer:

  if (nullableVariable != null && nullableVariable.someMethodCall()) {
      return true;
  }
  return fallbackIfNullMethodCall();


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

Search: