First, in this chapter, we tried to modify a local variable in a functional way. We cannot reuse the variable we created; instead, we have to create another one when we need to modify it. We also discussed the technique to modify the variable we passed to another function. Instead of passing the argument by value, we have to pass it by reference to make it change.
Then, we dug the use of the const
keyword to provide the immutable behavior to the function. By using this keyword, we can ensure that the variable inside the class cannot be modified. Another discussion was about applying the first-class and pure functions--things you learned in the previous chapter--to gain the power of immutability.
We also created the mutable class and then refactored it into an immutable class. We are now able to distinguish the mutable and immutable object and can apply it in our functional code. Lastly, in this chapter, we enumerated the benefit of the immutable object, so we are confident to use it...