{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/348","labels_url":"https://api.github.com/repos/facebook/immutable-js/issues/348/labels{/name}","comments_url":"https://api.github.com/repos/facebook/immutable-js/issues/348/comments","events_url":"https://api.github.com/repos/facebook/immutable-js/issues/348/events","html_url":"https://github.com/facebook/immutable-js/issues/348","id":59050183,"number":348,"title":"Explain how/why triple === equality works the way it does","user":{"login":"dchambers","id":283294,"avatar_url":"https://avatars.githubusercontent.com/u/283294?v=3","gravatar_id":"","url":"https://api.github.com/users/dchambers","html_url":"https://github.com/dchambers","followers_url":"https://api.github.com/users/dchambers/followers","following_url":"https://api.github.com/users/dchambers/following{/other_user}","gists_url":"https://api.github.com/users/dchambers/gists{/gist_id}","starred_url":"https://api.github.com/users/dchambers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchambers/subscriptions","organizations_url":"https://api.github.com/users/dchambers/orgs","repos_url":"https://api.github.com/users/dchambers/repos","events_url":"https://api.github.com/users/dchambers/events{/privacy}","received_events_url":"https://api.github.com/users/dchambers/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-26T10:17:45Z","updated_at":"2015-02-27T08:04:10Z","closed_at":null,"body":"Suppose I have a map `m` defined like this:\r\n\r\n```js\r\nvar m = Immutable.Map({x:1});\r\n```\r\n\r\nthen the following code snippet returns `true` as expected:\r\n\r\n```js\r\nm === m.set('x', 1);\r\n```\r\n\r\nBut, for some reason, this doesn't work:\r\n\r\n```js\r\nm === m.set('x', 10).set('x', 1); // unexpected failure #1\r\n```\r\n\r\nand even weirder, nor does this:\r\n\r\n```js\r\nm.set('y', 5) === m.set('y', 5); // unexpected failure #2\r\n```\r\n\r\nI have no experience with Clojure, and perhaps this stuff would be obvious to me if I did, but as a JavaScripter I think it would be great for the documentation to explicitly mention that this is what happens, and to provide an explanation of the rationale for this behaviour.\r\n\r\nAt present, I can only guess that failure case number 1 is too hard to do for more complex use cases, so it's avoided for all cases. As for failure case number 2, I'm baffled, and it almost makes me start doubt that there is any data structure sharing going on at all!\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/comments/76353107","html_url":"https://github.com/facebook/immutable-js/issues/348#issuecomment-76353107","issue_url":"https://api.github.com/repos/facebook/immutable-js/issues/348","id":76353107,"user":{"login":"dchambers","id":283294,"avatar_url":"https://avatars.githubusercontent.com/u/283294?v=3","gravatar_id":"","url":"https://api.github.com/users/dchambers","html_url":"https://github.com/dchambers","followers_url":"https://api.github.com/users/dchambers/followers","following_url":"https://api.github.com/users/dchambers/following{/other_user}","gists_url":"https://api.github.com/users/dchambers/gists{/gist_id}","starred_url":"https://api.github.com/users/dchambers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchambers/subscriptions","organizations_url":"https://api.github.com/users/dchambers/orgs","repos_url":"https://api.github.com/users/dchambers/repos","events_url":"https://api.github.com/users/dchambers/events{/privacy}","received_events_url":"https://api.github.com/users/dchambers/received_events","type":"User","site_admin":false},"created_at":"2015-02-27T08:04:10Z","updated_at":"2015-02-27T08:04:10Z","body":"Hi @leebyron,\r\n\r\nThanks for the very detailed response. I guess I just had some incorrect assumptions about what the structural sharing of immutable data using a trie actually looked like. I had supposed it involved a tree of information starting with a common shared root, where each addition involved the creation of a new branch, and where each modification involved the creation of a new branch from a different part of that common tree.\r\n\r\nWere it modelled like this, then `m.set('y', 5) === m.set('y', 5)` would evaluate to `true`, as would `Immutable.Map({x:1}) === Immutable.Map({x:1})` since it would just involve the same modification to the same common root for all map data of `{}`.\r\n\r\nI've tried Googling for a good explanation of the Clojure map trie data structure, but have struggled to find anything really comprehensive. Are you able to recommend a good resource, or would I need to read the source code?\r\n"}}