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
Written by Sebastian Rajo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Related Tags
#ruby
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#