From: Ferdous ara Date: 2012-11-22T07:36:43+09:00 Subject: how to increase variable inside the while loop Hi, my question might be confusing as its hard for me to make it clear, what i want is , something like bellow $i = 1 $num = linecount.to_i + 1 #$faulty_count = 0 while $i < $num do current-#{i} = current_result["#{server_name}-#$i"]["usable"] puts current-#{i} -------------- $i +=1 end Basically , i want to store value of current_result["#{servername}-#$i"]["usable"] in to a variable (incremental variable ) like current-#{i} , but the syntax is not right ?? what will be right way to do this ?? End gloal is, i will have another loop like $j = 1 $num = linecount.to_i + 1 #$faulty_count = 0 while $i < $num do current-#{j} = current_result["#{server_name}-#$j"]["usable"] puts current-#{j} -------------- $j +=1 end So after this, i wanted to do like this current-#{i} == current-#{j} but that syntax is wrong .. can any one please help me out .. -- Posted via http://www.ruby-forum.com/.