SA-MP Forums Archive
Are arrays reference-type or value-type in PAWN? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Are arrays reference-type or value-type in PAWN? (/showthread.php?tid=444445)



Are arrays reference-type or value-type in PAWN? - Cameryn - 16.06.2013

The reason for this question is that if the example code will alter the array from the argument or do I have to explicitly use the '&' reference operator?

pawn Code:
stock SomeFunction(somearray[], len = sizeof(somearray))
{
    somearray[0] = EOS;
    strcat(somearray, "Modified Array", len);
}

new anotherarray[16] = {'A', 'R', 'R', 'A', 'Y'}
SomeFunction(anotherarray, 16);
//Well now will the value of the array becomes "Modified Array" or stays "Array"?
// If it doesn't I have to reference it right?



Re: Are arrays reference-type or value-type in PAWN? - KingHual - 16.06.2013

You don't need the &, it should work as long as the parameter isn't a constant.


Re: Are arrays reference-type or value-type in PAWN? - Cameryn - 16.06.2013

Quote:
Originally Posted by king_hual
View Post
You don't need the &, it should work as long as the parameter isn't a constant.
Thanks!