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

I think I'd be ok with a `while` that looked like this:

  while (prev->next) {
      if (prev->next == entry) break;
      prev = prev->next;
  }
or even this:

  while (prev && prev->next != entry)
      prev = prev->next;
Both are reasonable enough that they wouldn't trigger my (pretty laissez faire) sense of "taste". My core point: checking for the end of the list should be non-negotiable.

The `for` is just extra icing: it creates a scope for `prev`; you can tell at a glance that it's traversing a list. The update is closer to the termination check. But yes, this bit is negotiable.



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

Search: