# Is there any way in ruby to create dynamic variables?
note sure, but no. There's no need 
# 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.
variables in ruby are just references to objects. and since ruby objects can be dynamic, variables are dynamic in a basic sense, but in an o-o way 
on your case, why not make box refer to a dynamic object, like a hash?
eg,
box={}
#=> {}
counter = 52
#=> 52
box[counter] = 'cat and dogs'
#=> "cat and dogs"
box[counter]
#=> "cat and dogs"
store anything you want,
box["myname"]="botp"
#=> "botp"
even store a proc and call it
box[42]=lambda{box[counter].upcase}
#=> #<Proc:0x028d31e4@(irb):9>
box
#=> {"myname"=>"botp", 52=>"cat and dogs", 42=>#<Proc:0x028d31e4@(irb):9>}
box[42].call
#=> "CAT AND DOGS"
and you can even let box, cleanup itself 
box["cleanup"]=lambda{box.clear}
#=> #<Proc:0x028c141c@(irb):19>
box["cleanup"].call
#=> {}
box
#=> {}
kind regards -botp
···
From: Marc Heiler [mailto:shevegen@linuxmail.org]