OK… finally got it
OK… finally got it working. 0~180 is outta range. I keep trying and got it in between 20~160. When you meet such problem you just have to keep trying…
OK… finally got it
OK… finally got it working. 0~180 is outta range. I keep trying and got it in between 20~160. When you meet such problem you just have to keep trying…
Yeh, the “switch” statement
Yeh, the “switch” statement works only on ordinal types; but the char-type is one: it is a number pointing to the relevant character in the charset; so it’s perfectly fine to use or refer to these numbers as a quoted character in a switch statement. (In most cases, is much easier to read and maintain than a long if-else-if, too.)
If you want to test a single variable for a multiple of different values / situations; a switch/case is usually the way to go. It’ll effectively do things with less CPU ticks: an “if” would be unnecessary comparing the same variable again and again, while the switch would only look at it (fetch it) once.
Depending on usage cases, switch-case also has a neat “fall-through” capability that allows to branch into more than 1 case, (something that an “if” cannot do that easily), which can be terribly useful in some situations…