From: Eric Hodel Date: 2009-09-01T09:27:25+09:00 Subject: Re: help on phps $$ equivalent in ruby On Aug 31, 2009, at 17:23, Arthur Rats wrote: > its not quite right, can you see what I am doing wrong > > e.g. i've got a lot of fields - so a short version of my situation > > fields = [["somthing"]] > > fields.each{|x| > eval "#{x[0]} = Someclass::Somemethod.new" > } > > puts something.text="asdfasdfasdf" > > text is method from the Somthingclass that should work, but I get > undefined variable for something.text Don't use eval this way, it's wrong, wrong, wrong. Use a Hash. result = {} fields.each do |field| result[field] = SomeClass.new end