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

This article is one my pet peeves. It always shows up in discussions as "proof" that 0 indexing is superior, but it hides under the carpet all the cases the where it is not. For instance, backwards iteration needs a "-1" and breaks with unsigned ints.

    for (i=N-1; i>=0; i--)
I like the argument that 0-based is better for offsets and 1-based is better for indexes: https://hisham.hm/2021/01/18/again-on-0-based-vs-1-based-ind...


  for (unsigned i = N - 1; i < N; --i)




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

Search: