Skip to content
Discussion options

You must be logged in to vote

Adding EqualityContract allows for precise control over whether subtypes are equal, or not.

See #3137 for more information

The difficulty with implementing value-based equality across a type hierarchy lies in ensuring symmetry - that the two values agree on the equality being applied. In order to ensure that, types with value-based equality (or any custom equality) that can participate in a hierarchy of mutually comparable objects must essentially agree on who implements their equality. They can do that by declaring a Type-valued virtual property EqualityContract in the root class of the hierarchy, with every derived type that alters equality overriding that to return its own type.

Replies: 6 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YairHalberstadt
Comment options

You must be logged in to vote
1 reply
@theunrepentantgeek
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants
Converted from issue

This discussion was converted from issue #3787 on November 16, 2020 06:38.