From: David Masover Date: 2009-12-08T17:05:06+09:00 Subject: Re: convert string into a variable object On Tuesday 08 December 2009 01:03:31 am Steve Wilhelm wrote: > Toon Willems wrote: > > On 07 Dec 2009, at 21:35, Ad Ad wrote: > >>> to do. > >> > >> doesnt require the creation of any sort of a container variable. > > > > A much better way to do this would be to store the city names in a hash. > > your code would then be: > > > > File.open(@file). each do |x| > > @hash[x] = true > > end > > Would it not be better to convert to symbols? Not if the cities are changing every day. Remember, symbols are never garbage collected -- they should _only_ be used when there is a finite and predictable number of possible symbols you might create. Otherwise, you have a slow memory leak -- and especially for something like this, you're not really going to get a performance boost out of it.