If I set one array equal to another, does that pass a copy of the object or does it just pass the reference to the new variable? When a function returns an array, does this pass an object or a reference? When you pass an array into a function, does it pass the object or a reference?
Are arrays passed by reference or by object?
Started by Serrath, Jun 09 2012 11:55 AM
5 replies to this topic
#1
Posted 09 June 2012 - 11:55 AM
#2
Posted 09 June 2012 - 12:19 PM
In every case it passes the value stored in the array to whatever you are passing to.
A[1] will still be 5
Arrray[0] = 5 ; A[1] = Array[0] ; Array[0] += 1 ;
A[1] will still be 5
#3
Posted 09 June 2012 - 12:23 PM
Like Alex said, you cannot pass arrays. arr actually just gives the value at arr[0,0].
If you wish to pass an array around, either put it in an object and pass the object or use ds_lists.
If you wish to pass an array around, either put it in an object and pass the object or use ds_lists.
Edited by Zeddy, 09 June 2012 - 12:24 PM.
#4
Posted 09 June 2012 - 01:22 PM
You can't pass arrays..? Dear lord... Can you use local arrays in scripts? i.e. Can I alter an object's arrays when I call a script from that object?
Edited by Serrath, 09 June 2012 - 01:33 PM.
#5
Posted 09 June 2012 - 01:43 PM
Yes and Yes. If you need the ability to pass them use one of the data structures (list for 1 dimension , grid or maps for 2+)
#6
Posted 09 June 2012 - 08:30 PM
Thanks!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











