Which one is better (switch and else if)
#1

Код:
if(var == 1)
{
    ///....
}
else if(var == 2)
{
    ///....
}
or

Код:
switch(var)
{
    case (0):
    {
        ///....
    }
    case (1):
    {
        ///....
    }
}
yes, whichever is faster and better..

What is the difference...
Reply
#2

Its same
switch is a bunch of IF functions
Reply
#3

Switch is faster processing, I believe, other than that, they do the same job.
Reply
#4

And switch() look a lot better imho. A lot more structurated.
Reply
#5

I don't know why, but a lot of people say, that switch faster methode
Reply
#6

They don't differ much from speed. Switch is often considered faster because it's much easier to optimize.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)