Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Parse error on input ‘<-’Forum ↗

Parse error on input ‘<-’

App Development5 posts2,213 views5 likesLast activity Jun 2020
AX
axnblueOP
Jun 2020
template PersonalContract
  with
    signat : Party
    h : Party
    number : Int
    

  where
    signatory  signat

    controller hos can
      ExtraFunc : Optional (ContractId Demo)
        do
                  
          if number == 1
          then
            **temp <- create Demo with**
              signat = signat
              h = h

            return (Some temp)
          else
            return None

                      
          


template Demo
  with
    signat : Party
    h : Party

  where
    signatory signat

DR
drsk
Jun 2020 2

Hi @axnbl
You’ll need a do after the then

    controller hos can
      ExtraFunc : Optional (ContractId Demo)
        do
          if number == 1
          then do
            temp <- create $ Demo with signat = signat, h = h
            return (Some temp)
          else
            return None

AX
axnblue
Jun 2020

But it will create the Demo Contract. I dont want to create it unless or until number == 1. Is there any other way to do that?

CO
cocreature
Jun 2020 2

That’s exactly what @drsk’s example will do. Adding the do does no tchange the fact that it will only be created if the number is 1.

AX
axnblue
Jun 2020 1

ohh okay… got it

AN
anthony
Jun 2021

2 posts were split to a new topic: Can we put do blocks directly in templates?

← Back to Discussions