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

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.

主站蜘蛛池模板: 江山市| 理塘县| 兖州市| 宾阳县| 云龙县| 彭山县| 景德镇市| 漠河县| 托克托县| 瑞昌市| 扎赉特旗| 花莲县| 芮城县| 独山县| 乐陵市| 共和县| 扶余县| 江孜县| 响水县| 石阡县| 启东市| 乾安县| 宾阳县| 兴海县| 南开区| 兴海县| 东辽县| 中江县| 峨山| 上虞市| 辉县市| 玉龙| 忻州市| 海城市| 普兰店市| 德清县| 桃园市| 屯留县| 铅山县| 石台县| 襄汾县|