官术网_书友最值得收藏!

Persisting changes

If data isn't supposed to change, just how are we supposed to get anything done? How do we move the state of an application along from one state to the next if our data is immutable? The answer is that every operation that you perform on immutable data creates new immutable data. These are called persistent changes, because the original data is persisted. The new data that's created as a result of running the operation contains the changes. When we call an operation on this new data, it returns new data, and so on.

What are we supposed to do with the old data when we make a persistent change that results in new data? The answer is – it depends. Sometimes, you'll just replace the old data with the new data. Yes, the variable is changed, but it's replaced with an entirely new reference. This means that something that is still referencing the old data is never affected by your persistent changes.

主站蜘蛛池模板: 大丰市| 山东省| 肇庆市| 宣化县| 上犹县| 丁青县| 芷江| 灵山县| 许昌县| 许昌县| 石楼县| 北川| 宣恩县| 白水县| 宁安市| 江西省| 锡林郭勒盟| 阿拉尔市| 郁南县| 花莲市| 额尔古纳市| 乳山市| 莒南县| 鹰潭市| 商丘市| 祁阳县| 海南省| 家居| 南城县| 灵宝市| 偏关县| 加查县| 铅山县| 广灵县| 喀喇| 信宜市| 三门县| 化德县| 科尔| 咸丰县| 沙雅县|