By default, structs have default methods for Equals and GetHashCode. The default implementations match what VS generates when selecting the autofix option.
Instead of implementing this interface on every struct just to use a == b
, does it make more sense to just use a.equals(b)
?
Comparing the two:
-
.equals
is a bit longer to type out, but equally readable. - writing less boilerplate helps maintain development velocity.
- relying on the default implementations avoids churn when adding new fields to the struct.
Thoughts?
(PS: Thanks for the great course!)