You can have mappings of mappings. For example:
Example 5-15. Mapping of mappings
mapping numbers = ([
"roman": ([
"i": 1,
"iv": 4,
"v": 5
]),
"english": ([
"1": 1,
"4": 4,
"5": 5
])
]);
numbers["roman"]["i"]; // this is 1
numbers["english"]["1"]; // this is also 1
Mappings can also be composed using the '*' operator (composed in the mathematical sense of the word):
mapping m1 = ([ ]), m2 = ([ ]), m3; m1["a"] = "b"; m2["b"] = "c"; m3 = m1 * m2 // // m3 = "a" -> "c" //
You may also add two mappings. The sum of two mappings is defined as the union of the two mappings.
mapping m1 = ([ ]), m2 = ([ ]), m3; m1["a"] = "b"; m2["b"] = "c"; m3 = m1 + m2; // // m3 = "a" -> "b" // "b" -> "c" //
The subtraction operator is not defined for mappings (use map_delete()).