-
-
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
Created Ternary operator file under Control Structure #684
base: master
Are you sure you want to change the base?
Conversation
Created a File for Ternary Operator
|
|
||
[float] | ||
=== Parameters | ||
`expression`. An expression is any legal combination of symbols that represents a value. |
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.
`expression`. An expression is any legal combination of symbols that represents a value. | |
`expression`: An expression is any legal combination of symbols that represents a value. |
Use standard format for parameter documentation:
reference-en/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Single_Entity.adoc
Line 43 in ac98490
`pin`: the number of the pin to write to. Allowed data types: int. |
int x = 10, y = 20, z; // declared and defined three variables x, y and z | ||
z = (x < y) ? x : y; |
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.
int x = 10, y = 20, z; // declared and defined three variables x, y and z | |
z = (x < y) ? x : y; | |
int x = 10; | |
int y = 20; | |
int z = (x < y) ? x : y; |
Beginners are likely to be unfamiliar with the ability to declare multiple variables in one statement. This is not documented in the Arduino Language Reference and they won't understand that the language contains all the capabilities of C++ and that the missing documentation for those capabilities can be found in any C++ reference, since this fact is not documented (#623).
In this case, using a separate statement for each declaration is actually just as good because the function of the code is now so clear that an explanatory comment is unnecessary.
|
||
[float] | ||
=== Example Code | ||
|
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.
The statement checks the conditional expression and assigns `z` the value of `x`, the expression `x<y` is `true`. | |
I think this location is more appropriate for the description, rather than the previous location as a comment at the end of the code block.
---- | ||
int x = 10, y = 20, z; // declared and defined three variables x, y and z | ||
z = (x < y) ? x : y; | ||
// the statement checks the conditional expression and assigns z the value of x, the expression x<y is true |
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.
// the statement checks the conditional expression and assigns z the value of x, the expression x<y is true |
This accompanies my suggestion above to move the description out of the code block.
Created a File for Ternary Operator under Control Structure
Ref: #519