--_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, 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, indeed a new object is indeed created every time an anonymous objects created. The only core object I know of for which this is not true is the symbol, 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 aeed for the symbol equivalent of a regexp. _________________________________________________________________ Hotmailhas ever-growing storage! DonÃÕ worry about storage limits. http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009-_fe319f55-2a15-460a-88df-7465fbd00c45_--