From: Jeremy Bopp Date: 2011-07-26T23:04:27+09:00 Subject: Re: Why aren't string literals treated similarly to symbols? On 7/26/2011 00:24, Yukihiro Matsumoto wrote: > Hi, > > It's because Ruby strings are mutable, just like array expression > makes a new instance of Array everytime. On the other hand, symbols > are immutable. Thank you for your response, matz. :-) Yes, strings are mutable, so that's why I suggested that the string instance given to the script be a dup of the string instance representing the actual literal. However, I realized after sleeping on this that a dup of a string instance still requires at least a minimal amount of object data to be allocated, so my naive suggestion wouldn't help very much except in the case of looping over code containing a large string literal that dwarfs the size of the basic object structure. That case by itself isn't likely very common, but it looks like it's already handled according to Robert. I'll try to take a look at the code Robert linked when I get some time to study it. -Jeremy