Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

animeshsrivastava24
Copy link
Contributor

Created a File for Ternary Operator under Control Structure
Ref: #519

Created a File for Ternary Operator
@animeshsrivastava24 animeshsrivastava24 changed the title Created Ternary operator file under Control Created Ternary operator file under Control Structure Jul 21, 2019
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.


[float]
=== Parameters
`expression`. An expression is any legal combination of symbols that represents a value.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`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:

`pin`: the number of the pin to write to. Allowed data types: int.

Comment on lines +47 to +48
int x = 10, y = 20, z; // declared and defined three variables x, y and z
z = (x < y) ? x : y;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

@per1234 per1234 self-assigned this Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants