Thread: else if vs if

  1. #1
    Set Apart -- jrahhali's Avatar
    Join Date
    Nov 2002
    Posts
    256

    else if vs if

    what's the difference/purpose of using a tree of else if(s) against a series of if(s)?

  2. #2
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    Location
    Europe
    Posts
    448
    Speed. A series of ifs will all be checked, but if, for example the first if condition is met, the rest in the if-else block will not be tested. This only works if the conditions are mutually exclusive, but if several can be met at once, you'd need to use a series of ifs, or a series of ef-else blocks.
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

Popular pages Recent additions subscribe to a feed