Writing Joystick Code: Part 3: Difference between revisions

Line 135: Line 135:


You can use more than one elseif, but it gets messy. If you have a number of tests then it is better to test for each case individually.
You can use more than one elseif, but it gets messy. If you have a number of tests then it is better to test for each case individually.
Easier to understand and much less chance of an error. Our above example would become
Easier to understand and much less chance of an error.
Our above example would become
   if (x < 5) {
   if (x < 5) {
     x = x + 2
     x = x + 2
224

edits