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

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.

主站蜘蛛池模板: 新安县| 茌平县| 冕宁县| 东辽县| 南投市| 翼城县| 桐梓县| 准格尔旗| 桐梓县| 宜兴市| 瓦房店市| 堆龙德庆县| 古蔺县| 宁强县| 兰西县| 沙洋县| 黄石市| 吐鲁番市| 弥渡县| 融水| 霍邱县| 吉安县| 浦城县| 绥阳县| 瑞昌市| 舟山市| 英山县| 内黄县| 鄂伦春自治旗| 信宜市| 泸州市| 汝阳县| 武川县| 寻乌县| 治多县| 洞口县| 甘南县| 商南县| 杨浦区| 黔东| 崇州市|