From: Martin Boese Date: 2008-07-01T23:16:37+09:00 Subject: Re: Dynamic Variables 'Object' has a method to define instance variables: irb(main):001:0> counter = 52 irb(main):002:0> self.instance_variable_set("@box#{counter}", 'cat and dogs') => "cat and dogs" irb(main):003:0> @box52 => "cat and dogs" martin On Tuesday 01 July 2008 10:45:48 Marc Heiler wrote: > Is there any way in ruby to create dynamic variables? > > counter = 52 > box#{counter} = "cat and dogs" > > There would be then a new variable > box52 > > Note that this is not a question whether someone should do it or not - > this is solely whether it is doable or not. Until today I thought it is > somehow possible with eval but I failed, so I assume it is not possible.