Hi,

you cannot change "living" Ruby code like you try to do. That is, you
cannot just inject a #{i} somewhere and have the Ruby interpreter
process it as if the value was actually in the code.

If you want to dynamically create variables, you either need
metaprogramming or eval() with the latter always being the last resort 
("eval() is evil"). For local variables, however, eval() is really the 
only
possibility -- which already shows there's something wrong.

If you want to collect values, use arrays like Joel suggested. Don't use
variables with an index appended to them. That's extremely ugly to work
with and just unclean.

You should also note that "while" loops and manual counter arithmetic is 
rather rare in Ruby. Unlike BASIC or C or something, Ruby is a high 
level language that relies on more intelligent methods like "upto" or 
"each" or "each_with_index". You rarely ever have to do this "i += 1" 
stuff.

-- 
Posted via http://www.ruby-forum.com/.