From: George Ogata Date: 2006-12-16T12:58:31+09:00 Subject: Re: Dynamic Variable Names On 12/16/06, Chris Martin wrote: > Is it possible to create dynamic variable names in ruby? > > For example, in PHP it's done like this > > $a = 1; > ${"myvar_{$a}"} = "some_value"; > > # $myvar_1 = "some_value" > ?> Hi Chris, Couldn't you just throw them in a hash? my_vars[a] = 'some value' It depends on what you're doing, but this often leads to other nice things, like not having your "dynamic variable" names collide with others that happen to be in scope, and being able to iterate through them, inspect them, pass them around as a unit, etc.