Skip to content

Conversation

@pkulikov
Copy link
Contributor

Snippets are moved to the samples repo: dotnet/samples#512

@BillWagner
Copy link
Member

closing and reopening to build with new snippets

Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

Overall, this is much improved @pkulikov The language is more clear and easier to understand.

I had one comment to address, and then this is ready to merge. I don't think we need a new sample for an enum comparison. I think it would be enough to say that == and != for enum types obey the same rules as the underlying integral type.


[!code-csharp-interactive[value types equality](~/samples/snippets/csharp/language-reference/operators/EqualityAndNonEqualityExamples.cs#ValueTypesEquality)]

By default, the `==` operator is not defined for a user-defined [struct](../keywords/struct.md) type. A user-defined type can [overload](#operator-overloadability) the `==` operator.
Copy link
Member

Choose a reason for hiding this comment

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

This should state that == is defined for enum types. That slipped through the cracks in the new (more clear) description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BillWagner indeed, as behavior for structs is described, enum case also should be stated explicitly. Thank you for the remark. I've added the clarification, please check the latest commit.

Copy link
Member

@BillWagner BillWagner Dec 14, 2018

Choose a reason for hiding this comment

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

@pkulikov I'll suggest this small word change:

"Two operands of the same enum type are equal if the ..."

It's a small change, but the text you have could be misinterpreted to support something like the following:

    enum Color
    {
        Red,
        Green,
        Blue
    }

    enum Status
    {
        Red,
        Yellow,
        Green
    }

// compare two enum operands:
 bool equal = (Status.Red == Color.Red); // CS0019 (operator == cannot be applied to ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BillWagner that's a good catch! Thanks. Fixed.

@BillWagner
Copy link
Member

Thanks @pkulikov

This looks great. I'll :shipit: as soon as the build finishes.

@BillWagner BillWagner merged commit 7a1aa27 into dotnet:master Dec 14, 2018
@pkulikov pkulikov deleted the revise-equality-operators branch December 14, 2018 18:10
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