Writing Joystick Code: Part 3: Difference between revisions

Jump to navigation Jump to search
Line 107: Line 107:
   }
   }
</syntaxhighlight>
</syntaxhighlight>
A common way to abbreivate such simple expression, is using shorthand operators like:
* +=
* -=
* *=
* /=
For example:
<syntaxhighlight lang="php">
  if (x < 5) {
    x += 2; # means x = x + 2
    y += 1; # means y = y + 1
  }
</syntaxhighlight>


Now lets pretend that we still want to increase x by 2 if it less than 5, and if it is 5 or more we want to add 1 to it. We use else.
Now lets pretend that we still want to increase x by 2 if it less than 5, and if it is 5 or more we want to add 1 to it. We use else.

Navigation menu