What is the '$' operator?

134 Views Asked by At

I come across some examples in the Daml documentation where the operator '$' is being used, but cannot fully understand its purpose.

Example:

submit alice $ create User with username = alice, following = []

Is it the same as do, like in:

submit alice do
  create User with username = alice, following = []

?

1

There are 1 best solutions below

0
On BEST ANSWER

The $ operator is a substitute for parenthesis. The example

submit alice $ create User with username = alice, following = []

is the same as

submit alice (create User with username = alice, following = [])

To complete, the do is used to declare a code block (more than one line of code):

test = scenario do
  alice <- getParty "Alice"
  bob <- getParty "Bob"
  ...

However, it can also be used in a single line of code:

submit alice do create User with username = alice, following = []