doubt ampersand - 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: doubt ampersand (
/showthread.php?tid=377949)
doubt ampersand -
Rodrigo. - 15.09.2012
Hello guys.
Well, I see in many codes, this:
pawn Код:
//exemple
stock Lyrics(&number, &lol)
This has the same function if I put it this way? :
pawn Код:
stock Lyrics(number, lol)
Does this change anything?...
Re: doubt ampersand -
BadgerLedger - 15.09.2012
the & is to return multiple values
https://sampwiki.blast.hk/wiki/Stocks
Re: doubt ampersand -
Vince - 15.09.2012
The ampersand means that the argument is to be passed as a reference, not as a value. If you pass arguments by value (the default) then the original value of the variable will not change. If you pass arguments by reference then they will. For example:
pawn Код:
new a = 42;
stock byRef(&value)
{
value++;
}
byRef(a);
printf("%d", a);
Will print 43. Whereas:
pawn Код:
new a = 42;
stock byVal(value)
{
value++;
}
byVal(a);
printf("%d", a);
Will still print 42.
Re: doubt ampersand -
Rodrigo. - 15.09.2012
wow, ok.
Thanks to 2.