4 ms·
This is also a gem: "Because list is already immutable there's no practical need to actually create a copy of the list-instance, therefore list and copy are the
by ofrzeta 8y ago
This is also a gem: "Because list is already immutable there's no practical need to actually create a copy of the list-instance, therefore list and copy are the same instance. However if you copy a mutable list, copy is indeed a new instance so it's garanteed there's no side-effects when mutating the original list"
So you can get a "reference" to the same data where one reference gives you the data immutably while the other one lets you change it. Sounds like a recipe for subtle bugs.
- chinhodado 8y ago> where one reference gives you the data immutably while the other one lets you change it What do you mean, it's not like that at all. You only get back the same object (same reference) if it detects the object was immutable to begin with.
- ofrzeta 8y agoOk, fine. That's just what I got from the quoted text. But I see that was wrong.