It could be good, or not.

One point about it is that this form does not explicitly specify the order of the iteration. Therefore I would only use it in cases where that is the intent, and even in that case, explicitly specify the type.

int main() {
  int numberArray[] = {
    100,
    200,
    300,
    400,
    500
  };
  for (int number: numberArray) {
    cout << number << " ";
  }
  return 0;
}

prints: 100 200 300 400 500 …. or does it? why not: 300 200 500 400 100 …. ?

We really need a loop like this, or better yet .. one that supports parallel operation. This would have been a good place to introduce it.

gnucap/manual/tech/rangeloop.txt · Last modified: 2022/11/25 01:40 by felixs
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Run by Debian Driven by DokuWiki