18.04.2012, 13:52
pawn Код:
// Alright, say we have some variable
new some_variable = 14;
// Now we need to do different things, depending on what it is.
// A neat way to do this is by using "switch".
// Now we say "alright, I want to compare some_variable to a bunch of things"
switch (some_variable) {
// Is it 1, 2, or 3?
case 1, 2, 3: {
printf("It's 1, 2, or 3!");
}
// Is it between 5 and 10?
case 5 .. 10: {
printf("It's between 5 and 10!");
}
// Is it 14?
case 14: {
printf("It's 14!");
}
// If it's none of the above "cases"
default: {
printf("I'm not sure what it is!");
}
}

