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

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.

主站蜘蛛池模板: 饶平县| 桐城市| 宝丰县| 遂平县| 昆山市| 牟定县| 抚松县| 建水县| 盐城市| 清镇市| 杭锦后旗| 武隆县| 阿拉善右旗| 阿合奇县| 遂昌县| 阿城市| 荣昌县| 伊宁市| 海林市| 霸州市| 泰顺县| 汝州市| 仪陇县| 广元市| 清新县| 纳雍县| 博客| 石楼县| 旬阳县| 道孚县| 高州市| 安图县| 仁寿县| 龙泉市| 巴青县| 万安县| 泊头市| 吉隆县| 福州市| 日土县| 黔西|