From: Ehsanul Hoque Date: 2009-09-28T01:12:28+09:00 Subject: Re: handling of regexp objects that aren't referenced by variables, arrays, tables or objects --_fe319f55-2a15-460a-88df-7465fbd00c45_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable > Is it the case that such "anonymous" objects like regexps (maybe also > strings?) are re-created whenever the code snippet they are defined in > is executed? If so=2C is there a convenient way of preventing this? Is > this only the case for regexps or also for strings and other objects? > (Why is it the case at all - I can't make any sense of it?) I would > like to learn how I can write Ruby code that is reasonably efficient > in this regard because the impact on execution time in the described > situation was so immense. (I'm currently using Ruby 1.9.1.) Yes=2C indeed a new object is indeed created every time an anonymous object= is created. The only core object I know of for which this is not true is t= he symbol=2C which is basically an immutable string. There may be others I'= m not aware of though. I suppose your code shows that there just might be a= need for the symbol equivalent of a regexp. =0A= _________________________________________________________________=0A= Hotmail=AE has ever-growing storage! Don=92t worry about storage limits.=0A= http://windowslive.com/Tutorial/Hotmail/Storage?ocid=3DTXT_TAGLM_WL_HM_Tuto= rial_Storage_062009= --_fe319f55-2a15-460a-88df-7465fbd00c45_--