Skip to content

Commit a885353

Browse files
Update switchCase.adoc
Moved the new example code to the "Notes and Warnings".
1 parent d05c66c commit a885353

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

Language/Structure/Control Structure/switchCase.adoc

+23-7
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ switch (var) {
5252
=== Returns
5353
Nothing
5454

55-
[float]
56-
=== Note
57-
58-
If you need to declare a variable in a case, use curly brackets {} to define a scope within the case statement to avoid a "crosses initialization of" compiler error.
59-
--
6055
// OVERVIEW SECTION ENDS
6156

6257

@@ -69,6 +64,29 @@ If you need to declare a variable in a case, use curly brackets {} to define a s
6964
[float]
7065
=== Example Code
7166

67+
[source,arduino]
68+
----
69+
switch (var) {
70+
case 1:
71+
//do something when var equals 1
72+
break;
73+
case 2:
74+
//do something when var equals 2
75+
break;
76+
default:
77+
// if nothing else matches, do the default
78+
// default is optional
79+
break;
80+
}
81+
82+
----
83+
[%hardbreaks]
84+
85+
86+
[float]
87+
=== Notes and Warnings
88+
// Add useful notes, tips, caveat, known issues, and warnings about this Reference term
89+
If you need to declare a variable in a case, use curly brackets {} to define a scope within the case statement to avoid a "crosses initialization of" compiler error.
7290
[source,arduino]
7391
----
7492
switch (var) {
@@ -85,9 +103,7 @@ switch (var) {
85103
// default is optional
86104
break;
87105
}
88-
89106
----
90-
[%hardbreaks]
91107

92108
--
93109
// HOW TO USE SECTION ENDS

0 commit comments

Comments
 (0)