ID:156963
 
I have a situation where i need the switch statement to act like it does in C++ or java or most other languages.


This is what I want my switch to look like, but in dm. Is there any shorthand way?
var/value
switch(card_value)
case 0:
value+=1
break
case 1: case 2:
value+=2
break
case 3: case 4: case 5: case 6:
value+=3
break

You could do this
mob/verb/test(n as num)
switch(n)
if(1 to 9)
world<<1
if(10 to 20)
world<<2



As for case x:, No.
In response to Leur (#1)
What about strings?

No dice for strings either?
In response to Tubutas (#2)
For strings you'd have to do them seperately.
switch(cake)
if("Stringname")
if("SecondStringName")
There is a way to specify multiple options (values) for a switch case in DM. I'm not going to bother telling you the specifics, though, since it takes the minimum of common sense to look up something you have a question about, especially before making a topic about it. This is simple info that is right there in the documentation.
<small>(Needless to say, unfortunately the same applies to those who tried to help)</small>
In response to Kaioken (#4)
I'ma smack you Kaioken >:{ Not really, but you are right. I didn't bother looking up switch() again. and I just did, and I now see why you said that. :3
In response to Leur (#5)
Thats impressive. Who knew the guide was so helpful.
In response to Tubutas (#6)
Oh yes, how impressive and surprising. The documentation explains things.
In response to Leur (#3)
No, you don't. You need to look up switch() in the Reference as well, apparently.
In response to Garthor (#8)
We covered that already in a different set of posts Garthor. xP
In response to Leur (#9)
Oh. I read the thread backwards.

Whooooooooops.