From: Brian Candler Date: 2010-04-25T18:20:02+09:00 Subject: Re: Rexml pretty printing "can't modify frozen string" Une B辿vue wrote: > for all s, doc and docs i get false to #.frozen? > what isn't working here ? An object might not be frozen, but one of the objects it contains (directly or indirectly) could be. Looking at the source line which raised the error, the String which is being squeezed is something returned by node.to_s Interestingly, the line before does a gsub!, and it seems that this is happy on a frozen string as long as no change is required: >> s = "aaa".freeze => "aaa" >> s.gsub!(/b/,'') => nil This is different from the behaviour of squeeze! >> s.squeeze! TypeError: can't modify frozen string from (irb):17:in `squeeze!' from (irb):17 -- Posted via http://www.ruby-forum.com/.