• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Difference between "else if" and "elseif"?

Status
Not open for further replies.
Level 12
Joined
Feb 22, 2010
Messages
1,115
With elseif you can check multiple situations about same thing.For example you want to do something depends on how much minutes elapsed in game.

JASS:
if (minutesElapsed < 10) then
    // do something
elseif (minutesElapsed < 30) then
    // do something else
elseif (minutesElapsed < 40) then
    // do something elsee
endif

When first if condition is true, it won't check other if conditions.If minutesElapsed is 5, it makes all 3 conditions true but only the first found one will work.

without elseif you need to do something like this

JASS:
if (minutesElapsed < 10) then
    // do something
else
    if (minutesElapsed < 30) then
        // do something else
    else
        if (minutesElapsed < 40) then
            // do something elsee
        endif
    endif
endif


Note:elseif just makes your work easier when it needs, it doesn't give you something you can't do.
 
Status
Not open for further replies.
Top