Assigning values to an array: This method assigns values to each element in the array.
Indexing into an array: This method takes the index of an element and returns the value of that element.
Appending elements to an array: This method adds new elements at the end of an existing array.
An array is a collection of objects that are stored in the same place. This allows the programmer to access them without having to search for them.
Ruby arrays can be manipulated in two ways - by using the [] operator or by using the methods defined on Array class. The [] operator is used to get or set the value of an array element while the methods are used to iterate over it, create new arrays, and sort them.
They are faster than other types of data structures
They can be indexed with numbers, strings, symbols and even objects
Array methods are:
Array#length - returns the number of elements in an array
Array#subarray - returns a new array with a subset of the original array's elements
Array#slice - returns a new array with a section of an original array's elements
Share a personalized message with your friends.