title: Ruby string mutability
body: <p>This may be a bit of a nooby question, I have been trying to get better at ruby recently, and started reading the fantastic <a href="http://oreilly.com/catalog/9780596516178/" rel="nofollow noreferrer">The Ruby Programming Language</a>. Something that was mentioned is that string literals are considered mutable, so in a loop it is better to use a variable then a literal, as a new string will get instantiated at every iteration.</p>
  
  <p>My question is why? At first I thought it was because of interpolation, but symbols are immutable and they support interpolation. Coming from a static background, it doesn't really make much sense to me.</p>
  
  <p>EDIT:</p>
  
  <p>After reading <a href="https://stackoverflow.com/users/210/thenduks">thenduks</a> answer, I think I may have it. AFAIK, languages like Java or C# don't have destructive string methods (they use upcase, but not upcase!). Because of things like upcase! or &lt;&lt;, the literal cannot be immutable.</p>
  
  <p>Not 100% sure on that, the other possibility is that it is a compile-time interning that happens, which is something that just doesn't happen in a scripting language.</p>