• 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] Is there an "In Case of" syntax in JASS?

Status
Not open for further replies.
Level 17
Joined
Apr 13, 2008
Messages
1,608
Hi, I was wondering if there is an In Case of syntax in JASS.
In other programming languages (delphi, for example) this serves as many ifs, for example:

In Case of YourInteger
1: yourcodeshere
2: here too please

Would have the same effect as:

If YourInteger == 1 then
yourcodeshere
else
If Youriteger == 2 then
your codes here too again please
endif
endif

Just the in case of syntax is much shorter, and much easier on the eye.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
JASS:
if YourInteger == 1 then
yourcodeshere
else
if Youriteger == 2 then
your codes here too again please
endif
endif

JASS:
if YourInteger == 1 then
yourcodeshere
elseif Youriteger == 2 then
your codes here too again please
endif

if != If :cwink:
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Last time I checked, it was (in C)

Code:
switch (YourInteger) {
    case 1:
        blahblah
        break;
    case 2:
        blahblah
        break;
    case 3:
        blahblah
        break;
    ...
}

Or replacing switch with case and case with when, for Ruby. (And also, block syntax instead of brace syntax).

Never seen it like that, though.

While it might be sort of nice, it is a kind of feature which is pretty much useless in terms of application in Wc3 other than pretty code.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
hmm lets see

if a == 1 then
actions
elseif a == 2 then
actions
endif

switch (a)
{
case 1;
actions;
break;
case 2;
actions;
break;
}

dont think there is more to say
 
Status
Not open for further replies.
Top