From: dohzya Date: 2007-07-25T22:13:15+09:00 Subject: Re: Creating instance variables while looping over a hash Le mercredi 25 juillet 2007 � 21:57 +0900, blaine a �crit : > I"m reading in a YAML file using the yaml library in Ruby. My YAML > looks something like this: > > config: > value1: Something here > value2: Something else > > As I loop from the YAML like: > > config["config"].each { |key, value| } > > How could I set the key as an instance variable with the value of the > value of the key... resulting in: > > @value1 = "Something here" > @value2 = "Something else" > > Any thoughts? > You should play with Object#instance_variable_set(name, value) -- Etienne Vallette d'Osia