how to unfreeze a string?

R

Ruby Newbee

x="hello "
x.freeze
x.concat "boy"
RuntimeError: can't modify frozen string

Then how to unfreeze a string?

Thanks.
 
S

Stefano Crocco

|x="hello "
|x.freeze
|x.concat "boy"
|RuntimeError: can't modify frozen string
|
|Then how to unfreeze a string?
|
|Thanks.
|

You can't remove the frozen state from an object. The best you can do is to
create a duplicate the object (using dup, not clone) and modify it.

Stefano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top