Delete multiple keys from Map

Hi Team,

How to delete multiple keys from a Map in Daml?

Key deletion for single element :
M.delete “ABC” dataMap

In similar to above what is the syntax to delete lets says “ABD” and “XYZ” keys from dataMap.

3 Likes

Hi @Sneha, you can chain multiple calls to delete, e.g.,

M.delete "ABD" (M.delete "XYZ" dataMap)

If you have a list, you can use foldl to delete all of them:

foldl (\acc key -> M.delete key acc) dataMap keysToDelete
2 Likes

This helps. Thank you @cocreature for quick response.

2 Likes