From: Morton Goldberg Date: 2007-02-20T11:11:19+09:00 Subject: Re: Strange question: Convert string to array name On Feb 19, 2007, at 8:10 PM, kenbo wrote: > Thanks for the folks that mentioned eval---I thought of that after the > posting but assumed that, as in LISP, there might be a better way > to accomplish > it :-) > > It's nice to see more similarities between LISP and Ruby. I don't know whether or not you will think this better than using 'eval', but in Ruby this kind of indirect reference problem can often be handled by introducing a hash. For example, a = %w{ one two three four five } b = %w{ six seven eight nine } h = {} h['a'] = a h['b'] = b foo = 'a' h[foo][2] # => "three" foo = 'b' h[foo][2] # => "eight" Regards, Morton