One of the tenets of functional programming is immutability.
Immutable values means that once a variable has been set, it can never change. It’s forever the same, immutable.
But wait a second, if a variable is frozen….doesn’t it mean that it no longer varies? which means it’s not longer a variable? exactly, it becomes a constant!
life_constant = "change" life_constant.freeze life_constant = "taxes"
If you try the above means you get a runtime error, as you can’t modify a frozen string.
Sidenote, no point freezing Fixnums as they are already immutable objects.
After having a chat with my mentors, it seems that there’s not much value in freezing objects. A particular reason why one would freeze an object is due to a lack of trust. Defensive programming. Being afraid that someone is going to mutate the object underneath your feet. Perhaps a better approach is teach your team and having a code base where the team doesn’t feel the need to mutate the object.
I’m not sure, what I am sure about is that using freeze is not idiomatic in ruby. Plus you would have freeze all over your codebase, which would be yuck.