Forum Discussion

FICO's avatar
FICO
Community Manager
2 years ago

I have an array where in I create a copy of that array in a local variable array , while changing the elements of local variable array it changes the main element of array . It is getting pass by refe

2 Replies

  • FICO's avatar
    FICO
    Community Manager

    Create a loop to go through and assign each item to the array by value.

    Assuming array a with the values you want to copy

    b is some array of (whatever type) initially an array of (whatever type).

    index is an integer initially 0.

    while index < a.count do

    {

    b[index] = a[index];

    increment index by 1;

    }

  • FICO's avatar
    FICO
    Community Manager

    @Tom Travis​ ; Well ! we have used User Vars array , we assign our Array A to userVars ,

    which helped us to resolve the problem of overwriting the main Array A ,

    BTW will implement your logic as well ,

    Thanks

    Suraj Kumar Jha(IDFC FIRST BANK)