From: Bauduin Raphael Date: 2004-01-19T03:50:03+09:00 Subject: Re: setting instance variable "dynamically" Thanks for the answers! In my class I now use this : instance_eval("@#{row[1]}=Translation.new(row)") Raph Mauricio Fern�ndez wrote: > On Mon, Jan 19, 2004 at 02:29:59AM +0900, Bauduin Raphael wrote: > >>I saw in the pickaxe there's a way to call methods dynamically, with >>send("method_name"): >> >>"test".send("length") # 4 >> >>What I want to do is set a variable this way. Is it possible? > > >>>class A; end; a = A.new > > => # > >>>a.instance_variable_set :@foo, "foo" > > => "foo" > >>>a > > => # > >>>a.instance_variable_get :@foo > > => "foo" >