Step 14: Array Index


A value’s position in an array is called its index. In most programming languages, counting is zero-indexed, meaning that the first item in a collection is item 0, and Ruby is no exception. We can access the item at a particular index using the array[index] syntax:

my_array = [1, 2, 3, 4, 5]
puts(my_array[1])
puts(my_array[3])