View Problem

Define an unmodifiable empty map

DiskEdit
clojure
; Clojure maps are immutable
(def m {})
DiskEdit
cpp
const std::map<T1,T2> immutable_map_instance_of_type_t1_to_t2;
ExpandDiskEdit
erlang

% Erlang data structures are immutable - updating a 'map' sees a modified copy created
Map = dict:new(),
ExpandDiskEdit
fantom
map := [:].ro
ExpandDiskEdit
fsharp
// Most native fsharp data structures are immutable - updating a 'map' sees a modified copy created
let map = Map.empty
DiskEdit
groovy
empty = Collections.EMPTY_MAP
DiskEdit
groovy
map = [:].asImmutable()
ExpandDiskEdit
groovy with commons collections
def empty = MapUtils.EMPTY_SORTED_MAP
ExpandDiskEdit
groovy with google collections
def empty = ImmutableMap.of()
DiskEdit
haskell
import qualified Data.Map as Map

output :: Map.Map k v
output = Map.empty
DiskEdit
ocaml
(* OCaml maps are functional data structures (so are immutable) *)
module StringMap = Map.Make (String)
let m = StringMap.empty
DiskEdit
python 2.6
import collections
EmptyDict = collections.namedtuple("EmptyDict", "")
e = EmptyDict()
DiskEdit
ruby
map = {}.freeze
ExpandDiskEdit
scala
val map = immutable.Map.empty
ExpandDiskEdit
scala
val map = immutable.TreeMap.empty[String, Int]
DiskEdit
scala
val map = Map()

Submit a new solution for clojure, cpp, erlang, fantom ...
There are 5 other solutions in additional languages (java, perl, or php)