aboutsummaryrefslogtreecommitdiffstats
path: root/source/arduino/break.rst
diff options
context:
space:
mode:
Diffstat (limited to 'source/arduino/break.rst')
-rw-r--r--source/arduino/break.rst12
1 files changed, 8 insertions, 4 deletions
diff --git a/source/arduino/break.rst b/source/arduino/break.rst
index d951c52..57009c1 100644
--- a/source/arduino/break.rst
+++ b/source/arduino/break.rst
@@ -1,12 +1,14 @@
+.. highlight:: cpp
+
.. _arduino-break:
break
=====
-**break** is used to exit from a **do**, **for**, or **while**
-loop, bypassing the normal loop condition. It is also used to exit
-from a **switch** statement.
-
+``break`` is used to exit from a :ref:`while <arduino-while>`\ ,
+:ref:`for <arduino-for>`\ , or :ref:`do/while <arduino-dowhile>` loop,
+bypassing the normal loop condition. It is also used to exit from a
+:ref:`switch <arduino-switchcase>` statement.
Example
@@ -20,6 +22,8 @@ Example
sens = analogRead(sensorPin);
if (sens > threshold){ // bail out on sensor detect
x = 0;
+ // this line of code means that we'll immediately exit
+ // from the "for" loop:
break;
}
delay(50);