Unable to update a value in Verse from one to another.

 var MyArray: [ ]int = array{1, 7, 49, 32, 29}


OnBegin<override>()<suspends>:void=
    
    if(Num:=MyArray[0]):
        for (Item: MyArray):
            if (Item > Num):
               Num:=Item

Trying to set up an array to get the largest value. All is well except for the last line of code. Do not seem to be able to assign the value of Item to Num.

Main error is the data is ambiguous but not clear how to resolve this. Any thoughts or alternative way to do this are greatly appreciated.

Num needs to be a var to be able to be changed. What I would do is declare Num outside the if.

var Num : int = 0

Then change the if to read:

if (set Num = MyArray[0])

And change the last line to:

set Num = Item

1 Like

Thank you! This helped me to resolve this.

Using the := I reassigned it to a NewVar, then was able to replace that for Num, and reassigned finally worked!!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.