merge
Merge accepts two or more arguments of type map
and returns a new map
containing key-value pairs from all the map
s. If any key appears more than once, it will be associated to the value coming in last. This function is not recursive, means any map
inside a map
won't be merged but treated same as any other value.
A list
can also be given containing two or more items of type map
which will be expanded internally into arguments.
merge(map1, map2, ...)
# Or
merge(listOfMaps)
#
Parametersmap1
: Amap
that needs to be mergedmap2
: Amap
that needs to be mergedlistOfMaps
:list
containingmap
s that needs to be merged together
#
Returns- Merged
map
#
Exampleprint(merge({orders: 10, shipment: 5}, {stock: 500, revenue: 3000}))# prints: {orders: 10, shipments: 5, stock: 500, revenue: 3000}