Use a variable (or a constant) as an array index
array = ["Hello", "there", "AAA", 1, 2, 3]
index_value = 0
puts array[index_value] #prints "Hello"
index_value = 1
puts array[index_value] #prints "there"
index_value = 2
puts array[index_value] #prints "AAA"
Related examples in the same category