Mega Code Archive

 
Categories / Ruby / String
 

Make a string immutable with Objects freeze method

greet = "Hello, myValue!" greet.freeze # try to append something greet.concat("!") # => TypeError: can't modify frozen string # is the object frozen? greet.frozen? # => true