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

I agree. I also find unless statements to be difficult to read. I use this pattern all of the time in my JavaScript:

  if(!foo) {
    maybeDoSomething();

    return;
  }

  bar();
This lets me early exit, if needed, while letting the meat of the function not suffer from unnecessary indentation.

The unless statement makes the early exit seem like the default action rather than the exceptional action it (hopefully) is.



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

Search: