From: Robert Klemme Date: 2006-08-12T04:55:16+09:00 Subject: Re: newbie question: how to create variable Karel Michek wrote: > Hi, > > how to create variable in the method that accepts string as name of the variable and the object? > > Something like this: > > class InterpreterCallback > def set_object(name, value) > #do something here instance_variable_set("@#{name}", value) > end > end > > $callback = InterpreterCallback.new() > $callback.set_object("var", 3) > > puts var > >>>> 3 > Alternatively you can use an OpenStruct. Kind regards robert