You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We had this code the other day where something produced a list[?str] and then we try to compare it like if my_list == ["a", "b"] and this doesn't compile... but I feel it should. I don't know exactly how, but it should. Clearly, if a list contains some None elements, it can't equal a list that only contains str. Similarly, for if foo == ["a", None], since the foo list starts with a None, then it's obvious that it won't equal the list we compare with since the first element "a" is a str, which clearly isn't None, so the overall result of this list comparison must be false. I don't understand enough of how Eq on a list works to know what needs to do what in order to support this, but it feels doable and all these checks around None are silly.
Everything could have a default Eq implementation that is the same as Identity, so if it's the actual same instance, then it's Eq==True, otherwise False. That would be enough to make the comparison in the example work and maybe it's useful for other things too.
The text was updated successfully, but these errors were encountered:
We had this code the other day where something produced a
list[?str]
and then we try to compare it likeif my_list == ["a", "b"]
and this doesn't compile... but I feel it should. I don't know exactly how, but it should. Clearly, if a list contains some None elements, it can't equal a list that only contains str. Similarly, forif foo == ["a", None]
, since thefoo
list starts with a None, then it's obvious that it won't equal the list we compare with since the first element "a" is a str, which clearly isn't None, so the overall result of this list comparison must be false. I don't understand enough of how Eq on a list works to know what needs to do what in order to support this, but it feels doable and all these checks around None are silly.Everything could have a default Eq implementation that is the same as Identity, so if it's the actual same instance, then it's Eq==True, otherwise False. That would be enough to make the comparison in the example work and maybe it's useful for other things too.
The text was updated successfully, but these errors were encountered: