From: dblack@... Date: 2006-09-11T03:31:00+09:00 Subject: Re: patching strings together to make a variable Hi -- On Mon, 11 Sep 2006, Axis Sivitz wrote: > Uh...if you have so many similarly named variables, it sounds like you > should be using an array or a map. > > The map could be set up with the keys (a certain string) indexing to > the values of your old variables. > > @some_map['var'] = "pass" > > def test(string) > puts @some_map[string] > end > > test('var') #=> "pass" Which brings us back to: > http://www.perl.org :-) Perl has these "soft" or "symbolic" > references, plus a whole chorus of people to tell you that you > should use hashes instead :-) :-) David -- David A. Black | dblack@wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org