Merges the indicated map-like objects to return a new map.
If you have two maps:
$ cat data1.yaml
a: The letter A
b: The letter B
c: This will be overwritten when merged
$ cat data2.yaml
c: The letter C
d: The letter D
e: The letter E
You can merge them into a single map:
$ ori Tree.merge data1.yaml, data2.yaml
a: The letter A
b: The letter B
c: The letter C
d: The letter D
e: The letter E
The keys of the merged map are the unique keys of the constituent maps in the order the maps are given.
When asked for a key, the merged map asks each of the constituent maps in reverse order for that key. If a map returns a defined value for that key, that value is used. In this example, getting c returns the result from data2.yaml, because that is the first map (in reverse order) that defines a value for c.
The Origami language also supports a spread operator that can perform the same kind of merge using ... three periods or the … ellipsis character:
$ ori { ...data1.yaml, ...data2.yaml }
a: The letter A
b: The letter B
c: The letter C
d: The letter D
e: The letter E
The merge operation is shallow; for a deep merge operation, see deepMerge.