From: Marnen Laibow-Koser Date: 2009-11-24T00:46:02+09:00 Subject: Re: More on psuedo arrays; Better way? Ralph Shnelvar wrote: > BC> Marnen Laibow-Koser wrote: >>>> Is there a better way to do this? >>> >>> x.send("x#{rand(i % N_X_METHODS)]".to_sym)) > > BC> And you don't need to_sym either. > > This x.send() will be executed a million times. > > Doesn't that have a fairly high overhead? Won't a million symbols be > generated? In my case ... with the m array, only 20 symbols would be > generated. > > Does it matter? > > Is it possible to run out of symbols? Do you know the difference between symbols and strings? A million strings may be generated (and quickly GC'd), but only 20 symbols will. What are you trying to do here, anyway? I strongly suspect that there's a better approach thanyour pseudoarray. If you can describe the use case, I'll see what comes to mind. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.