Navigation
Synopsis Union of two maps.
Syntax Exp1 + Exp2
Types
Exp1 Exp2 Exp1 + Exp2
map[TK1, TV1] map[TK2, TV2] map[lub(TK1,TK2),lub(TK1,TK2) ]
Description The result is the union of the two map values of Exp1 and Exp2. If they have a pair with the same key in common, that key will be associated in the union with the value associated with that key in Exp2.
Examples
rascal>("apple": 1, "pear": 2) + ("banana": 3, "kiwi": 4);
map[str, int]: ("banana":3,"pear":2,"kiwi":4,"apple":1)
rascal>("apple": 1, "pear": 2) + ("banana": 3, "apple": 4);
map[str, int]: ("banana":3,"pear":2,"apple":4)
Benefits Map union is very suited for representing environment composition in interpreters.
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.