Which one is better (switch and else if) - 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: Which one is better (switch and else if) (
/showthread.php?tid=297119)
Which one is better (switch and else if) -
DayaKisteme - 14.11.2011
Код:
if(var == 1)
{
///....
}
else if(var == 2)
{
///....
}
or
Код:
switch(var)
{
case (0):
{
///....
}
case (1):
{
///....
}
}
yes, whichever is faster and better..
What is the difference...
Re: Which one is better (switch and else if) -
DRIFT_HUNTER - 14.11.2011
Its same
switch is a bunch of IF functions
Re: Which one is better (switch and else if) -
Redirect Left - 14.11.2011
Switch is faster processing, I believe, other than that, they do the same job.
Re: Which one is better (switch and else if) - [03]Garsino - 14.11.2011
And switch() look a lot better imho. A lot more structurated.
Re: Which one is better (switch and else if) -
juraska - 14.11.2011
I don't know why, but a lot of people say, that switch faster methode
Re: Which one is better (switch and else if) -
Tr1viUm - 16.11.2011
They don't differ much from speed. Switch is often considered faster because it's much easier to optimize.