Logo

Programming-Idioms

History of Idiom 7 > diff from v106 to v107

Edit summary for version 107 by adery:
[C++] news

Version 106

2021-03-23, 09:48:00

Version 107

2021-03-29, 02:55:32

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Variables
i,x,items
Variables
i,x,items
Extra Keywords
indices traverse traversal
Extra Keywords
indices traverse traversal
Imports
#include <iostream>
Imports
#include <iostream>
Code
for (std::size_t ix = 0; ix < items.size(); ++ix) {
  std::cout << "Item " << ix << " = " << items[ix] << std::endl;
}
Code
for (std::size_t ix = 0; ix < items.size(); ++ix) {
  if (8 == ix)
	return true;
}