Jump to content

Are Arrays Passed by Reference?


Haravikk

Recommended Posts

Arrays defenitely passed by reference to a function. In other case my mod will never works.

 

Blimey you're right! I had to run a bonafide test, which I really should have done at an earlier point... I've been messing around with expensive global functions too much.

 

 

 

 

Int[] arrayone
Event OnInit()

 

arrayone = new int[5]
arrayone[0] = 10
arrayone[1] = 20
arrayone[2] = 30
arrayone[3] = 40
arrayone[4] = 50
int[] arraytwo = passthearray(arrayone)
justchangethearray(arrayone)
print(arraytwo)
print(arrayone)
EndEvent
Int[] Function passthearray(Int[] receive)
receive[0] = 1
receive[1] = 2
receive[2] = 3
receive[3] = 4
receive[4] = 5
return receive
EndFunction
Function justchangethearray(Int[] receive2)
receive2[0] = 15
receive2[1] = 25
receive2[2] = 35
receive2[3] = 45
receive2[4] = 55
EndFunction

 

[15, 25, 35, 45, 55]
[15, 25, 35, 45, 55]

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...