2

I have a choice defined as:

MyChoice: ( ContractId X, ContractId X )
        ....
        return ( a, b )

How do I use a or b in a scenario as an argument for something else? Dot notation doesn't appear to work.

user3293336
  • 121
  • 1
  • This is a duplicate of ["How do I extract the components of a tuple in DAML?"](https://stackoverflow.com/questions/53763514/how-do-i-extract-the-components-of-a-tuple-in-daml). It boils down to extracting the components from a tuple. – bame Feb 05 '19 at 10:29

1 Answers1

2

You can use ._1 and ._2 as accessors; or you can use fst and snd as functions to extract the elements.

You can also bind the components of a pair using pattern matching when the choice is exercised, like so:

somecode = do
   (x,y) <- exercise myCid MyChoice with ...
   doStuffWith x
   doStuffWIth y