Ellipsis operator (...) - 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: Ellipsis operator (...) (
/showthread.php?tid=488705)
Ellipsis operator (...) -
sammp - 18.01.2014
Am I doing this right? xD
pawn Код:
stock MultiplyNumber(...)
{
new result = 0;
for(new i = 0; i < numargs(); ++i)
{
result *= getarg(i);
}
return result;
}
stock DivideNumber(...)
{
new result = 0;
for(new i = 0; i < numargs(); ++i)
{
result /= getarg(i);
}
return result;
}
stock SubtractNumber(...)
{
new result = 0;
for(new i = 0; i < numargs(); ++i)
{
result -= getarg(i);
}
return result;
}
Re: Ellipsis operator (...) -
sammp - 19.01.2014
Anyone?
AW: Ellipsis operator (...) -
Nero_3D - 19.01.2014
You should first get an arg if you use multiplication or division otherwise it is just (0 * x or 0 / x)
For subtracting and addition they are both the same just the first as a minus in front of it
Just test your code and you will see if it worked
Eventhough I don't see any use of variadic parameters because each only need two, even if they are just test functions
Re: Ellipsis operator (...) -
sammp - 19.01.2014
Alright, thanks