| ▲ | tantalor 3 hours ago | |
> Compared to i++ from C/C++ or forEach from JavaScript, Python's version just works. Comparing to forEach in JS is incorrect because forEach is an method of Array. You should compare it to `for...of` in JS. Both operate on iterators. Article is missing an important distinction between iterators and other "array like" types (including strings): Iterators don't have to stop, e.g., they can take from a generator that never ceases. Both Python and JS are happy to loop forever if the iterator never stops. | ||
| ▲ | quietbritishjim 3 hours ago | parent [-] | |
There's also the range based for loop in C++. An actual comparison of iterator-style loops might be interesting but this article is a pretty vacuous bit of basic Python. It's also a confusing title, given that Scratch is the name of a programming language. | ||