From: Harry Kakueki Date: 2012-08-31T11:07:09+09:00 Subject: Re: Load an array of 10 ratings by position # > srand > > rating=[] > result=[] > aux=[] > > n=10 > > for i in 0..n-1 > rating[i]=rand(10)+1 > end > > > for i in 4..n-1 # Why is this 4 ? This gives you nils in aux > aux[i]=rating[i] > end > > aux.reverse! > > for i in 0..n-1 > result[i]=rating[i]+aux[i] > end > > > puts "#{rating}" > puts "#{result}" > ########################################### > > Up to half of the array works fine, but after following values > generates bad. > > Thanks. > I'm not sure I understand your question, but you get an error because you have nils in aux. See the comment I added to your code. Harry