We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The implementation of Maybe class in The Maybe functor post https://blog.ploeh.dk/2018/03/26/the-maybe-functor/ has a little issue, when T is a value type. For example:
new Maybe<int>().Equals(new Maybe<int>(0)) // true
Maybe it is better to put a class constraint for T in Maybe<T>, or implement Equals like this?
Maybe<T>
public override bool Equals(object obj) { var other = obj as Maybe<T>; if (other == null) return false; return !this.HasItem && !other.HasItem || this.HasItem && other.HasItem && object.Equals(this.Item, other.Item); }
The text was updated successfully, but these errors were encountered:
Yes, good catch, that's a bug, it should check HasItem as well.
HasItem
Sorry, something went wrong.
No branches or pull requests
The implementation of Maybe class in The Maybe functor post https://blog.ploeh.dk/2018/03/26/the-maybe-functor/ has a little issue, when T is a value type. For example:
Maybe it is better to put a class constraint for T in
Maybe<T>
, or implement Equals like this?The text was updated successfully, but these errors were encountered: