For multidimensional arrays you need to decide in which order you
iterate
over the indices. There’s more than one convention to do so. Typical
order
1: The inner loop iterates over the first, the next outermost loop over
the second index, and so on.
Typical order 2: The inner loop iterates over the last, the next
outermost loop over the previous index, and so on.
for m in 0 … 5
if x[m][0] >= x[2][0] then
printf(“Greater %3.3f\n”, x[m][0])
else
printf(“Smaller %3.3f \n”, x[m][0] )
end
end
puts “Smallest value = #{x[5][0].to_s}”
And it works fine.
Best regards,
Thiel
Josef ‘Jupp’ Schugt schreef:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.