-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
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
List should be Hashable #3611
Comments
If we get this, we probably don't need Related: http://code.google.com/p/dart/issues/detail?id=3597 |
Strongly disagree. List is mutable. It's easy to add/remove items from it. If the hashCode of list is a function of its items and it's changed after it's added to a HashSet, it can be effectively lost--future attempts to find it will use the new hashCode while it's stored in buckets based on its old hashCode. |
This comment was originally written by [email protected] Some lists are mutable, some lists are not. 'You should not mutate lists that are keys of a hashtable' is definitely more complex than 'lists may not be keys of a hashtable'. It's also much more useful. |
Added Area-Library, Triaged labels. |
This comment was originally written by [email protected] Tom: I agree Object should be hashable with identity semantics, but IMO List should be hashable with value semantics, so this is a different bug and I think we need both. I was practicing some interview questions today, and had to switch back to Java because of this bug :-( |
This comment was originally written by @seaneagan this issue should be equivalent to issue #2217, which requests a value-based == for Collections, since == and hashCode must be consistent with one another. |
Changes: ``` > git log --format="%C(auto) %h %s" 817e61d..b9afe92 https://dart.googlesource.com/pub.git/+/b9afe927 Completely switch from pub.dartlang.org to pub.dev (#3611) https://dart.googlesource.com/pub.git/+/7b65fa73 update docs for running 'pub token' (#3602) https://dart.googlesource.com/pub.git/+/4c9ebd0e Content hashing of archives (#3482) ``` Diff: https://dart.googlesource.com/pub.git/+/817e61d9eb174f77dfd2cb1d1de45826f66ac6bf~..b9afe9270c24d040b8ae465b4b37ba4f7f4b4cc5/ Change-Id: I6d827dd64f822e0194e0e17e95a47f02b744b561 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264701 Commit-Queue: Sigurd Meldgaard <[email protected]> Reviewed-by: Jonas Jensen <[email protected]>
This issue was originally filed by [email protected]
and have a hashCode defined in terms of the hashCodes of its elements (like in Java).
Currently this would throw if an element wasn't hashable, if 3369 was fixed it would always be defined.
Ideally Map and Set too...
The text was updated successfully, but these errors were encountered: