4 ms·
> The beauty of a for loop is that you can do _anything_ with it. That’s also the curse: a generic loop can be almost anything (looping over an iterable can't
by dragonwriter 5y ago
> The beauty of a for loop is that you can do _anything_ with it.
That’s also the curse: a generic loop can be almost anything (looping over an iterable can't quite express anything, but it can do a lot), so seeing it tells you nothing.
C-style loops can do more (literally anything), and loop-over-iterable syntax has been generally preferred where it can be applied because it tells you more (even if only a little more) about what the block of code is doing up-front.
Constructs that are more specific than loop-over-iterable can be correspondingly more expressive.