Here’s an example of two different dictionaries, yet they return the same hash code. Why?
https://gist.github.com/837861
(They aren’t the same object)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Hashes aren’t guaranteed to be distinct for distinct objects. In fact, hash collisions will happen. The only two properties the
-hashmethod is supposed to guarantee are (both taken from the documentation):If two objects are equal (as determined by the isEqual: method), they must have the same hash value.
If a mutable object is added to a collection that uses hash values to determine the object’s position in the collection, the value returned by the hash method of the object must not change while the object is in the collection.