Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    818
    Reputation
    125
    Thanks
    1,785
    My Mood
    Doh
    Just found this small article, Seems I am not the only one who tests loops for performance, K given the fact that its .net he is talking about and is no way meant to be compared to C++ but it just goes to show that the Switch Statement is fast just like in Delphi

    Switch vs If

  2. #17
    Xlilzoosk8rX's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    the-ville, PA
    Posts
    358
    Reputation
    24
    Thanks
    53
    they both work the same.
    Even though "swirch " may be faster,
    it not faster by much.
    Its barely enough to notice to humans perception.
    Plus using switch you may lagg if you dont
    do it the right way, causing your memory to
    just pour out everywhere (mem leaks) lol

    I myself preffer to use IF and ELSE
    its a lot more code friendly to people that are just learning.

  3. #18
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    818
    Reputation
    125
    Thanks
    1,785
    My Mood
    Doh
    I myself preffer to use IF and ELSE
    its a lot more code friendly to people that are just learning.
    I have to disagree on that, Switch is clearly more readable than if statements, its more logical for new people coming into programming, People using if statements all the time have more than likely picked this habit up from other sources, for example programmers who have come from vb to C++ and then the new person learning c++ has picked up the habit.

    c++ - Switch vs if-else - Stack Overflow

  4. #19
    _Fk127_'s Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    724
    Reputation
    16
    Thanks
    208
    My Mood
    Bitchy
    Quote Originally Posted by Xlilzoosk8rX View Post
    they both work the same.
    Even though "swirch " may be faster,
    it not faster by much.
    Its barely enough to notice to humans perception.
    Plus using switch you may lagg if you dont
    do it the right way, causing your memory to
    just pour out everywhere (mem leaks) lol

    I myself preffer to use IF and ELSE
    its a lot more code friendly to people that are just learning.
    i dont see what is so confusing about
    switch(variable)
    {
    case 1:
    //whatever
    break;

    case 2:
    //whatever
    break;

    default:
    //whatever
    break;
    }



    Put this image in your signature if you support HTML5 development!

Page 2 of 2 FirstFirst 12