Skip to main content

merge

Merge accepts two or more arguments of type map and returns a new map containing key-value pairs from all the maps. 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)

Parameters#

  • map1: A map that needs to be merged
  • map2: A map that needs to be merged
  • listOfMaps: list containing maps that needs to be merged together

Returns#

  • Merged map

Example#

print(merge({orders: 10, shipment: 5}, {stock: 500, revenue: 3000}))# prints: {orders: 10, shipments: 5, stock: 500, revenue: 3000}