Hacker News new | ask | show | jobs
by thdc 2080 days ago
I don't necessarily think what you don't like is related to early returns because the code in the article could be written like

  if (!status.hasInsurance()){
    return 1;
  }
  if (status.hasInsurance() && status.isTotaled()){
    return 10000;
  }
  // ...
to be explicit about the conditions. Or without early returns but with still the same issue:

  if (!status.hasInsurance()) {
    amount = 1;
  } else if (status.isTotaled()) {
    amount = 10000;
  }
  // ... return amount