Logo

Programming-Idioms

# 244 Print a map
Print the contents of the map m to the standard output: keys and values.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
#include <map>
#include <iostream>
for (auto entry : m) {
	std::cout << entry.first << ": " << entry.second << "\n";
}
using System;
Console.WriteLine(string.Join(Environment.NewLine, m));
print(m);
IO.inspect m
import "fmt"
fmt.Printf("%q", m)
import "fmt"
fmt.Println(m)
console.log(m);
console.table(m);
import java.util.Map;
System.out.println(m);
m.forEach((k, v) -> {
    out.println(k + " = " + v);
});
import static java.lang.System.out;
m.entrySet().forEach(out::println);
uses Generics.Collections;
for APair in m do writeln(APair.Key, APair.Value);
print "$_: $m{$_}\n" for keys %m;
print(m)
puts m
println!("{:?}", m);