"Iterate without an index"

28 views
Skip to first unread message

Lam

unread,
Apr 11, 2011, 9:23:25 AM4/11/11
to javapractices-dot-com-discuss
I find articles on javapractices very ambiguous - that many of the
articles promote beliefs above and beyond what its title suggests.

For example, "Iterate without an index".

I fully agree that for each and iterators should be preferred over the
use of indices if the index is not used for any other purpose than the
iteration.

However, to say "In addition, the (rather unnatural) computer science
tradition of starting loop indexes from 0 instead of 1 is a continual
source of trivial errors" is ignorant. Starting from 0 is the most
natural thing to do, and you'll run into problems and run into edge
cases sooner or later if you don't start with 0.

Reply all
Reply to author
Forward
0 new messages