Posts: 1,767
Threads: 124
Joined: Mar 2010
Quote:
Originally Posted by [XST]O_x
Switch-case? It's one of the simplest things around pawn.
It can replace if conditionals and sometimes save up some space aswell.
Example:
pawn Код:
if(a == b) { //Do something } else if(a == c) { //Do something } else if(a == d || a == e || a == f) { //Do something }
That is equal to:
pawn Код:
switch(a) { case b: { //Do something } case c: { //Do something } case d, e, f: { //Do something } }
It's quite useful if you're checking a single varible for various values.
|
You forget about default (else). However, this example(s) is/are the best:
https://sampwiki.blast.hk/wiki/Control_Structures#switch
You got everything explained there.