Skip to content

Revise the AND operator articles - #8687

Merged
rpetrusha merged 4 commits into
dotnet:masterfrom
pkulikov:revise-and-operator
Oct 30, 2018
Merged

rpetrusha merged 4 commits into
dotnet:masterfrom
pkulikov:revise-and-operator

Conversation

@pkulikov

Copy link
Copy Markdown
Contributor

This PR revises AND operator reference articles:

  • splits articles into the sections
  • adds links to the C# spec and relevant links to the programming guide
  • moves operator overloadability information to the end of the topic at the dedicated section. Reasoning: I assume overloadability is not the first thing to mention at the reference page. Moreover, the dedicated section helps to find that information on the page. (Also applied those changes to the + and += reference pages.)
  • at last, updates (use the latest language features) and moves snippets to the samples repo: Added AND operator snippets samples#420

@rpetrusha

Copy link
Copy Markdown
Contributor

Closing and reopening to begin new build.

@rpetrusha rpetrusha closed this Oct 29, 2018
@rpetrusha rpetrusha reopened this Oct 29, 2018
@rpetrusha
rpetrusha self-requested a review October 29, 2018 17:40

[!code-csharp-interactive[+= examples](~/samples/snippets/csharp/language-reference/operators/AdditionExamples.cs#AddAndAssign)]

## Operator overloadability

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Moving this paragraph and adding this section is a huge improvement, @pkulikov!

@rpetrusha rpetrusha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a really nice revision. I did leave two comments for you to consider, @pkulikov, although if you disagree with them, I'll just merge your PR as is.


For [bool](../keywords/bool.md) operands, the `&` operator computes the logical AND of its operands. The result of `x & y` is `true` if both `x` and `y` are `true`. Otherwise, the result is `false`.

The `&` operator evaluates both operands regardless of the value of its first operand, as the following example shows:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm wondering whether this could use some additional detail or rephrasing. For example, "The & operator evaluates both operands even if the value of the first operand is false, so that the result must be false." My concern here is that inexperienced developers may not realize what this means.


[!code-csharp-interactive[bool logical AND](~/samples/snippets/csharp/language-reference/operators/AndOperatorExamples.cs#BooleanOperands)]

The [conditional AND operator](conditional-and-operator.md) `&&` also computes the logical AND of its operands, but evaluates the second operand only if necessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here again, the "only if necessary" means that the first operand is true.

@pkulikov

Copy link
Copy Markdown
Contributor Author

@rpetrusha thanks a lot for the review. I agree with you: article can be made more explicit. I've made additional changes; please check them.

@rpetrusha

Copy link
Copy Markdown
Contributor

This looks good, @pkulikov. Thanks for improving this article. I'll merge your PR now.

@rpetrusha
rpetrusha merged commit 4ee2381 into dotnet:master Oct 30, 2018
@pkulikov
pkulikov deleted the revise-and-operator branch October 30, 2018 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants