Last Updated: February 25, 2016
·
821
· elecay

Basic Ruby - Freeze

All mutables objects can be frozen by the freeze method:

string = "Hello World"
string.freeze
string.frozen? # => true
string[0] = "h" # => can't modify frozen String

Once that an object has been frozen, there is no way to thaw it.

You can copy a frozen object with clone or dup but the copy with clone will be frozen too.

--
The Ruby Programming Language by Flanagan & Matsumoto