Jump to content
Sign in to follow this  
Daantjeeuh

Question about switch statement

Recommended Posts

Is there a way to check for multiple values in a switch statement? Like this:

switch (_unit) do {

[indent]case unit1: case unit2: {[/indent]




[indent][indent]// Code here[/indent]

[/indent]


[indent]};[/indent]




[indent]case unit3: case unit4: {[/indent]




[indent][indent]// Code here[/indent]

[/indent]


[indent]};[/indent]




[indent]default {[/indent]




[indent][indent]// Code here[/indent]

[/indent]


[indent]};[/indent]


};

Edited by Daantjeeuh

Share this post


Link to post
Share on other sites
switch (true) do {
case (_unit in [unit1, unit2]): {...};
case ((_unit == unit3) or {_unit == unit4}): {...};
...
};

Share this post


Link to post
Share on other sites

Maybe something like this?

switch true do
{
case (_unit == unit1 OR (unit == unit2)):{};
case (_unit == unit3 OR (unit == unit4)):{};
};

Share this post


Link to post
Share on other sites
switch (_unit) do {
   case unit1; case unit2: {
       // Code here
   };
   case unit3; case unit4: {
       // Code here
   };
   default {
       // Code here
   };
};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×