Skip to content
CCPEDIAby Unity Nodes
App Development

Delete multiple keys from Map

3 posts474 views7 likesLast activity Sep 2020

  1. SnehaOP 3

    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.

  2. cocreature 2

    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
    
  3. Sneha 2

    This helps. Thank you @cocreature for quick response.