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

If I'm intentionally writing a one-line if I will write it on one line. I think using an indented second line without braces is less clear, and more prone to problems later when the code is modified.

So I'd write:

  if (max > 0) printf("%s", longest);

or

  if (max > 0) {
    printf("%s", longest);
  }
but never

  if (max > 0)
    printf("%s", longest);


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

Search: