An array is a data structure that contains a list of values called elements. Arrays can be an ordered, integer-indexed collection of any object. Ruby arrays can have objects such as Integer, String, Symbol, Fixnum, and Hash, or even other arrays, as elements. In many languages, arrays are rigid in terms of their size. In Ruby, however, an array increases its size as elements are added.
When we say ordered, we mean that the array will keep track of how the elements are inserted or removed from it. While fetching the data from an array, we can retrieve the values directly based on the position of the element. This will become clearer as we dive into the depths of data extraction and manipulation using arrays.
Integer-indexed means that each element in the array is linked to an index. In Ruby, we can fetch the data from an array based on the index irrespective of the value at that location. Like most other languages, array indexes in Ruby start from zero.
Ruby is very...