Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Pascal

Idiom #244 Print a map

Print the contents of the map m to the standard output: keys and values.

uses Generics.Collections;
for APair in m do writeln(APair.Key, APair.Value);
#include <map>
#include <iostream>
for (auto entry : m) {
	std::cout << entry.first << ": " << entry.second << "\n";
}

Range-based for loop since C++11.

New implementation...