Comment

Comment by andybak

With regard to C-style for loops - other than familiarity - why?

It always struck me as a fairly warty syntax.

Consider Python where you usually do:

    for item in iterator
If you want an integer sequence it's:

   for integer in range(1, 100)
and for those rare occurrences where you need an integer index as well:

    for index, item in enumerate(iterator) 
Swift seems to have a similar approach. Why would you ever want the C-style iterators?
parent andybak 10 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton