3 ms·
That's not reproducable. Hashes are reconstructed from the original data even if it no longer exists as a formal in memory object. This is just a random ID.
by kevin_thibedeau 9y ago
That's not reproducable. Hashes are reconstructed from the original data even if it no longer exists as a formal in memory object. This is just a random ID.
- AgentME 9y agoJavascript Maps and Sets key off of the object's identity, not its contents.
- kevin_thibedeau 9y agoThat's all great. It isn't a hash, which by definition requires a hashing function applied to transform input data.
- ninkendo 9y agoShouldn’t they just call the attribute “objectIdentity” then? The fact that it’s used to access a hash table in some use cases doesn’t make it a “hash code”. You’d just as well call it an “equality checking code”, or name it after any other use case you could think of for a unique identifier. Ruby calls its equivalent construct “object_id” and that makes so much more sense.
- munificent 9y agoFor mutable objects in an OOP language, the object's identity is "the original data". The values that may happen to be stored in any other fields at various points in time are not part of the object's state and cannot affect the hash code. (If they could, mutating the object would change its hash code, which would be Very Bad.)