diff options
author | Marti Bolivar <mbolivar@mit.edu> | 2010-11-28 11:23:33 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@mit.edu> | 2010-11-28 11:23:33 -0500 |
commit | d9cbd78e29d42e70bb46641dd43ee0772c8c975f (patch) | |
tree | 80a67cba4468dbcd89b3cd23ad56695b1f146c66 /source/arduino/else.rst | |
parent | 546b34076d230b617ba86defb6b90cd934b01878 (diff) | |
download | librambutan-d9cbd78e29d42e70bb46641dd43ee0772c8c975f.tar.gz librambutan-d9cbd78e29d42e70bb46641dd43ee0772c8c975f.zip |
reorganized all the arduino/ docs into a lang/ subdirectory since
they're properly CC attributed now.
Diffstat (limited to 'source/arduino/else.rst')
-rw-r--r-- | source/arduino/else.rst | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/source/arduino/else.rst b/source/arduino/else.rst deleted file mode 100644 index 9345e8a..0000000 --- a/source/arduino/else.rst +++ /dev/null @@ -1,54 +0,0 @@ -.. highlight:: cpp - -.. _arduino-else: - -if/else -======= - -``if``/\ ``else`` allows greater control over the flow of code than -the basic :ref:`if <arduino-if>` statement, by allowing multiple tests -to be grouped together. For example, an :ref:`analog input -<arduino-analogread>` could be tested, with one action taken if the -input was less than 500, and another action taken if the input was 500 -or greater. The code would look like this:: - - if (pinFiveInput < 500) { - // action A - } else { - // action B - } - -``else`` can precede another ``if`` test, so that multiple, mutually -exclusive tests can be run at the same time. - -Each test will proceed to the next one until a true test is -encountered. When a true test is found, its associated block of code -is run, and the program then skips to the line following the entire -if/else construction. If no test proves to be true, the default -``else`` block is executed, if one is present, and sets the default -behavior. - - -Note that an ``else if`` block may be used with or without a -terminating ``else`` block, and vice-versa. An unlimited number of -such ``else if`` branches is allowed. Here is a code example:: - - if (pinFiveInput < 500) { - // do Thing A - } else if (pinFiveInput >= 1000) { - // do Thing B - } else { - // do Thing C - } - -Another way to express branching, mutually exclusive tests, is with a -:ref:`switch/case <arduino-switchcase>` statement. - -See Also --------- - -- :ref:`if <arduino-if>` -- :ref:`switch/case <arduino-switchcase>` - - -.. include:: cc-attribution.txt
\ No newline at end of file |