Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Delete multiple keys from MapForum ↗

Delete multiple keys from Map

App Development3 posts440 views7 likesLast activity Sep 2020
SN
SnehaOP
Sep 2020

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.

CO
cocreature
Sep 2020

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
SN
Sneha
Sep 2020

This helps. Thank you @cocreature for quick response.

← Back to Discussions