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

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.

主站蜘蛛池模板: 隆回县| 乐安县| 革吉县| 渝中区| 崇文区| 黑龙江省| 诸城市| 敖汉旗| 邵阳市| 厦门市| 蓝田县| 尉犁县| 四子王旗| 朔州市| 永州市| 莒南县| 改则县| 通江县| 洪江市| 吉林省| 东丰县| 紫阳县| 卢湾区| 澄城县| 崇文区| 安达市| 越西县| 朔州市| 东乡| 徐州市| 韶山市| 广河县| 萝北县| 云浮市| 宁远县| 肇庆市| 化州市| 乐昌市| 象州县| 安阳市| 昔阳县|