Arrays as arguments

Hi
I noticed that when passing an array as an argument of a method the array is modified as if the method worked directly on the array and not just on its value.
It is very counter intuitive for me

What should I do to prevent changes to the original array ?
thanks

Arrays and objects are passed by reference not by value.

Create a private copy of the Array with ArrayA = ArrayB for eyample.

Only intrinsic datatypes are passed byval, all others are passed byref

http://developer.xojo.com/data-types
http://developer.xojo.com/byref (see blue section)

Create a new array and copy the values across one at a time (as long as your array holds intrinsic types of course), if you create a new array and assign one array to the other, you will be back at square one as you’re just pointing the new one to the old one.

Ooops! Thank you @ for this important fact. :slight_smile: