-
-
Notifications
You must be signed in to change notification settings - Fork 732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update switchCase.adoc #695
base: master
Are you sure you want to change the base?
Changes from all commits
27be376
a85306e
a3c74ae
d05c66c
a885353
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -52,7 +52,6 @@ switch (var) { | |||||
=== Returns | ||||||
Nothing | ||||||
|
||||||
-- | ||||||
// OVERVIEW SECTION ENDS | ||||||
|
||||||
|
||||||
|
@@ -71,7 +70,7 @@ switch (var) { | |||||
case 1: | ||||||
//do something when var equals 1 | ||||||
break; | ||||||
case 2: | ||||||
per1234 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
case 2: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Remove the trailing space that snuck in here as part of the proposal. |
||||||
//do something when var equals 2 | ||||||
break; | ||||||
default: | ||||||
|
@@ -83,6 +82,29 @@ switch (var) { | |||||
---- | ||||||
[%hardbreaks] | ||||||
|
||||||
|
||||||
[float] | ||||||
=== Notes and Warnings | ||||||
// Add useful notes, tips, caveat, known issues, and warnings about this Reference term | ||||||
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. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
[source,arduino] | ||||||
---- | ||||||
switch (var) { | ||||||
case 1: | ||||||
//do something when var equals 1 | ||||||
break; | ||||||
case 2: { | ||||||
//do something when var equals 2 | ||||||
int var2 = 1337; //to declare a variable you need the curly brackets | ||||||
break; | ||||||
} | ||||||
default: | ||||||
// if nothing else matches, do the default | ||||||
// default is optional | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This information does not add any value to the demonstration of the use of braces to create a scope in a case and has already been mentioned in the existing general example sketch. |
||||||
break; | ||||||
} | ||||||
---- | ||||||
|
||||||
-- | ||||||
// HOW TO USE SECTION ENDS | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block delimiter markup is required in order for the document to be valid AsciiDoc.