๐Ÿคธโ€โ™‚๏ธUnderlying type comparison

Why is there no implementation of IEquatable and IComparable on the underlying type?

Premise : It would be cool if we could check for equality and be able to compare a value object with a primitive type.

We could implement IEquatable<PrimitiveType> and IComparable<PrimitiveType> on the value object but it would be one sided.

See the following:

var name = Name.From("Joe");
name.Equals("Joe"); // Returns true
"Joe".Equals(name); // Returns false

Due to the inconsistency, no equality or comparison will be implemented on the underlying type.

Last updated