-
-
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?
Conversation
A good thing to know, A had a lot of trubleshooting befor I found out. ;)
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.
Thanks for your pull request @Mikkel-danielsen. I also think this would be a useful thing to document. I have some suggestions for improvements.
Co-Authored-By: per1234 <[email protected]>
Co-Authored-By: per1234 <[email protected]>
Co-Authored-By: per1234 <[email protected]>
Moved the new example code to the "Notes and Warnings".
Are there somthing I need to do here now? I am not sure how this works. |
@@ -71,7 +70,7 @@ switch (var) { | |||
case 1: | |||
//do something when var equals 1 | |||
break; | |||
case 2: | |||
case 2: |
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.
case 2: | |
case 2: |
Remove the trailing space that snuck in here as part of the proposal.
@@ -52,7 +52,6 @@ switch (var) { | |||
=== Returns | |||
Nothing | |||
|
|||
-- |
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.
[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 comment
The reason will be displayed to describe this comment to others. Learn more.
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. | |
If you need to declare a variable for use in a case, use link:../../further-syntax/curlybraces[curly braces] (`{`, `}`) to define a scope within the case statement to avoid a "crosses initialization of" compiler error. |
- Make it a little bit more clear why the reader might declare a variable in a case.
- Use Arduino's preferred name for braces: https://www.arduino.cc/reference/en/language/structure/further-syntax/curlybraces/
- Link to "curly braces" reference page
- Improve formatting of braces symbols
} | ||
default: | ||
// if nothing else matches, do the default | ||
// default is optional |
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.
// default is optional |
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.
Hi @Mikkel-danielsen. I wanted to check back in with you. If you will update the pull request according to the instructions I provided above I will be happy to merge this valuable pull request. |
A good thing to know, I had a lot of trubleshooting befor I found out. ;)
You get no errors. The first case with variable declaration works, but noe case after it.