Method Equals
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
Equals(object?)
Gives true when the given object is a Maybe<T> of this type equal to this one.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare against.
Returns
- bool
true if
objis a Maybe<T> of the same type which operator ==(Maybe<T>, Maybe<T>) considers equal to this one.
Remarks
Equals(Maybe<T>)
Gives true when the given instance is equal to this one.
public bool Equals(Maybe<T> other)
Parameters
otherMaybe<T>The instance to compare against.
Returns
- bool
true if operator ==(Maybe<T>, Maybe<T>) considers the two equal.
Remarks
The same compare as operator ==(Maybe<T>, Maybe<T>), with the name Default looks for. Without it, this struct has no IEquatable<T> and sends each compare through Equals(object?), which boxes the two operands. That occurs on each Distinct<TSource>(IEnumerable<TSource>) , Contains<TSource>(IEnumerable<TSource>, TSource) , IndexOf(T), and dictionary lookup. A struct is how this type avoids an allocation, and that made it allocate in the collection-heavy code that notices.